Split a report so each manager sees only their region
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
- Join valid orders to
data/customers.csvand calculate each order's net value. - Write one file per region,
lab/deliver/orders-REGION.csv, with headerorder_id,order_date,region,net_value, holding only that region's orders. - Write
lab/deliver/access.csvwith headerrole,report: one row for each regional manager naming their file, and one row forfinancewith 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.