Automating a weekly report from CSV files
An automated weekly report should show which records it includes and which need review. Start with two CSV exports and test how they are combined before connecting your systems.
Define what each row represents
Set the reporting period, the file sources, and the required fields. In this example, each row is a snapshot of an inquiry. The fields are an inquiry ID, a team, and a status. The ID identifies the same inquiry across two files.
Decide how to handle two identical rows and two rows with the same ID and different values. This example counts identical copies once. Conflicting data goes to review with its source files and the reason.
Run the rules on a small data set
The sample has seven rows across two files. Three valid inquiries make it into the report, two open and one closed. There is one duplicate row and two inquiries to review, one with a missing status and one with conflicting statuses.
Download and run the weekly report sample. It uses fictional data and Python’s standard library. The output separates the summary, duplicate count, and issues.
Decide when a report is ready to share
Record which files the report used, the reporting period, and any issues that need attention. If an expected file is absent, mark the report as partial and route it for review.
During a pilot, compare the summary with one manually prepared report. Check the counts by status, the records flagged for review, and whether you can rerun the same period. Agree on who approves the report before it is shared.
Where does the data come from?
| Source | When it fits | Watch out for |
|---|---|---|
| A CSV exported by hand | There is no other access, or as a start | Someone must remember to export, for the same time window |
| The system’s API | The system allows scheduled retrieval | Permissions, rate limits and version changes |
| A shared sheet | The team already works in it | Renamed columns, and deleted rows |
How do you send the report, and what happens when a run fails?
- Send it where the team already reads: an email with a short summary and a link, or a message in the work channel.
- Summary first: how many inquiries, how many open, and what is unusual this week.
- When a file is missing or the run fails, the report is not sent as if all is well. An alert goes to whoever is responsible instead.
- Keep every report sent, so you can compare week with week.
On what to do when an automation stops, see what to do when a business automation stops.
A weekly report automation brief
- Sources and period
- List expected files, the cutoff time, and the time zone.
- Identifiers and fields
- Set a stable ID, required fields, and which source owns each field.
- Exceptions
- Agree on how to handle repeats, missing fields, conflicts, and absent files.
- Handover check
- Compare the output with a manual report and name the person who approves it.