{"id":"code-work-fin-bank-csv-stdlib-clean","audience":"finance","category":"coding","track":"coding","technique":"constraints","title":"Clean a UK bank export with plain Python, no pandas","free":false,"task":"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.","materialLabel":"First lines of the bank export (attached to your prompt automatically)","material":"bank_export.csv (first 8 lines, opened in a text editor)\n\nTxn Date,Value Date,Description,Reference,Amount,Balance\n03/11/2026,03/11/2026,CARD PAYMENT KOPA OFFICE,REF88213,\"(1,250.00)\",\"14,220.10\"\n04/11/2026,05/11/2026,BACS CREDIT LAKEVIEW DENTAL,INV-3301,\"4,200.00\",\"18,420.10\"\n04/11/2026,04/11/2026,DIRECT DEBIT FLEETLINE INS,DD-0091,(310.45),\"18,109.65\"\n12/11/2026,12/11/2026,FASTER PMT R MEHTA EXPENSES,EXP-221,(86.20),\"18,023.45\"\n13/11/2026,13/11/2026,BANK CHARGE,,(15.00),\"18,008.45\"\n\nNotes from Ama (bookkeeper):\n- The export is about 300 rows a month.\n- Value Date is when the money actually cleared; we don't use it.\n- The bank changed its export format in March and added the Reference column.\n- The cleaned file gets imported into Ledgerly, which only accepts three columns.\n- Card payments over $1,000 need a receipt attached in Ledgerly.\n- Last year we did this by hand in a spreadsheet every month, which took about two hours.\n- Balance is the running total after each line and isn't needed.","rules":[{"type":"codeBlocks","count":1},{"type":"maxCodeLines","max":20},{"type":"maxProseWords","max":25}],"mistakes":[{"title":"Not saying what's installed","why":"The AI reaches for pandas, which isn't on the shared laptop.","fix":"Add: \"Standard library only, no pandas.\"","checks":["r0"]},{"title":"Not saying where the bank is","why":"The AI reads 03/11 as March 11, so every date shifts.","fix":"Add: \"Dates are day/month/year (UK).\"","checks":["r1"]},{"title":"Not explaining the parentheses","why":"The AI keeps (1,250.00) as text or as a positive number.","fix":"Add: \"Parentheses mean negative: (1,250.00) becomes -1250.00.\"","checks":["r2"]},{"title":"Getting a menu of options","why":"The AI likes to offer two or three versions of the script, so you're left to pick and test them yourself.","fix":"Add: \"Give one script only, in one code block, no alternatives.\"","checks":["codeBlocks","maxCodeLines"]},{"title":"Getting a tutorial","why":"By default the AI explains every part of the code at length, which you then have to scroll past.","fix":"Add: \"After the code, one line under 15 words. Nothing else.\"","checks":["maxProseWords"]}],"promptHints":[{"label":"Rules out pandas","patterns":["standard library","no pandas","csv module","built-?in"]},{"label":"Gives the date order","patterns":["day/month","dd/mm","uk","%d/%m"]},{"label":"Explains negative amounts","patterns":["parenthes","negative","money out"]},{"label":"Lists the output columns","patterns":["date.{0,15}description.{0,15}amount","header"]},{"label":"Caps the code length","patterns":["\\d+\\s*lines","at most","under \\d+","short"]}],"hint":"Two facts change everything here: which country the bank is in and what's installed on the laptop. Tell the AI both, plus what the parentheses mean.","rubricLabels":["Uses only the standard library (csv and datetime, no pandas) and writes a header row Date,Description,Amount to cleaned.csv","Reads Txn Date as day/month/year (such as strptime with %d/%m/%Y) and writes it as YYYY-MM-DD, so 03/11/2026 becomes 2026-11-03","Removes commas and turns amounts in parentheses into negatives, so (1,250.00) becomes -1250.00 and 4,200.00 becomes 4200.00"]}