Library › Coding AI › Finance and accounting
Clean a UK bank export with plain Python, no pandas
Practice: Setting limits and rules. About 5 minutes.
About this exercise
Write a Python script that reads bank_export.csv and writes cleaned.csv with only Date, Description and Amount, keeping a header row. The bank is in the UK, so dates are day/month/year and must come out as YYYY-MM-DD. Amounts in parentheses are money out and must become negative numbers without commas, e.g. (1,250.00) becomes -1250.00. Use only Python's standard library, because pandas isn't installed on the shared laptop. One code block, at most 20 lines, then under 25 words outside the code.
Common mistakes when you ask AI for this
- Not saying what's installed. The AI reaches for pandas, which isn't on the shared laptop. Try: Add: "Standard library only, no pandas."
- Not saying where the bank is. The AI reads 03/11 as March 11, so every date shifts. Try: Add: "Dates are day/month/year (UK)."
- Not explaining the parentheses. The AI keeps (1,250.00) as text or as a positive number. Try: Add: "Parentheses mean negative: (1,250.00) becomes -1250.00."
- Getting a menu of options. The AI likes to offer two or three versions of the script, so you're left to pick and test them yourself. Try: Add: "Give one script only, in one code block, no alternatives."
- Getting a tutorial. By default the AI explains every part of the code at length, which you then have to scroll past. Try: Add: "After the code, one line under 15 words. Nothing else."
What a strong prompt includes
- Rules out pandas
- Gives the date order
- Explains negative amounts
- Lists the output columns
- Caps the code length
Related exercises
- Add a cron line that matches the others in a crontab (Coding AI · Product managers)
- Add dark mode by overriding your existing CSS variables (Coding AI · Software developers)
- Add input checks to your number guessing game (Coding AI · High school students)
- Add input validation to a Java method with exact messages (Coding AI · Software developers)
- Add labels to a signup form without rewriting the page (Coding AI · High school students)