Split a report so each manager sees only their region

short · 35 min · Objective 4.2

Task

Four regional managers may each see their own region's orders, and finance may see all of them. Produce the per-region files and the access list that says who gets which.

Steps

  1. Join valid orders to data/customers.csv and calculate each order's net value.
  2. Write one file per region, lab/deliver/orders-REGION.csv, with header order_id,order_date,region,net_value, holding only that region's orders.
  3. Write lab/deliver/access.csv with header role,report: one row for each regional manager naming their file, and one row for finance with the report *.

Verify

These checks run in a POSIX shell with Python 3: Terminal on macOS or Linux, and on Windows Git Bash (it comes with Git for Windows) or WSL. On Windows, python3 is often a Microsoft Store placeholder that prints “Python was not found”; run alias python3=py in Git Bash first.

for f in lab/deliver/orders-*.csv; do echo "$(basename "$f"): $(($(wc -l < "$f") - 1)) rows, $(cut -d, -f3 "$f" | tail -n +2 | sort -u | wc -l) region"; done
awk -F, 'NR>1' lab/deliver/access.csv | wc -l

East 503 rows, North 515, South 519 and West 460 -- 1997 in all -- each file holding exactly 1 region, and 5 access rows. Splitting the data is stronger than filtering a shared dashboard: a filter can be cleared by whoever is looking, but a file that never contained the other regions cannot show them.

This is an independent study companion for CompTIA Data+ DA0-002 and is not produced by or endorsed by CompTIA.