"Clean up sales.csv"
You have `sales.csv`: 40,000 rows, dates in three formats, stray spaces, some repeated rows. You type:
▸ You: clean up sales.csv
The agent writes a script, runs it, and replies:
◂ Agent: Cleaned sales.csv. 39,812 rows, all dates normalised.
Your file has been rewritten. Which 188 rows are gone, and were they really duplicates? With the original overwritten, how would you check, or get it back?
The code is easy; your files are at stake
Throwaway scripts suit agents well. They are short and follow well-known patterns. The danger is what the script does to your files. The agent read maybe 20 of 40,000 rows and guessed the rest. A rename can silently replace a file that already has the new name. Overwriting the input leaves nothing to compare against. Data chores rarely have tests, so mistakes stay quiet. Your job: make mistakes **harmless** and **visible**.
Copy, sample, spot-check, then run
1. **Copy** the data into a working folder, e.g. `work/`. Leave the original outside the project folder, and don't approve anything that touches it.
2. Ask for a script that **writes a new file** and never changes its input. For renames or deletes, ask for a **dry run** first: it prints `old → new` and changes nothing.
3. **Run it yourself on a small sample** (20 rows, 10 files). Pick the sample by hand so it includes odd cases: blanks, accents, unusual formats.
4. **Spot-check**: compare counts in and out, and open a few outputs, especially the odd cases.
5. Then run it on the full copy and check the counts again.
A data-chore prompt
Goal, context, constraints and check, as before. The constraints protect the data. The check makes the script report numbers you can verify. Real customer data? Give the agent a made-up sample with the same columns, then run the finished script yourself.
▸ You: Write clean.py to tidy work/sales.csv.
Goal: dates as YYYY-MM-DD, trim spaces in
the name column, then drop rows that are
exact duplicates after that cleaning.
Context: dates are day/month (UK), e.g.
03/04/2024 = 3 April.
Constraints: take an input path and an
output path; write a NEW file and never
change the input. Use only Python's
built-in csv module.
Check: print rows in, rows out, duplicates
dropped. First run it on work/sample.csv
(20 rows) and stop so I can look.
The counts don't add up
The agent reports that the sample worked. You run it yourself:
$ python clean.py work/sample.csv work/out.csv
rows in: 20, rows out: 18, duplicates dropped: 1
One row is unaccounted for. You compare the two files and find that the row with an empty date silently vanished. You tell the agent: keep such rows with a blank date, and report how many. You rerun the sample:
$ python clean.py work/sample.csv work/out.csv
rows in: 20, rows out: 19, duplicates dropped: 1, blank dates kept: 1
Now 19 out + 1 duplicate = 20 in: every row is accounted for. Then you run the full copy and check the counts again.
Make mistakes cheap and loud
Work on a copy and write to a new file, or dry-run renames first. Try a small sample with odd cases. Check that the counts add up, and look at a few outputs before the full run. You replace the original yourself, at the very end.
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.