🧠 AI Learning Hub

Hub › Lessons › Lesson 5

Lesson 5 · Freelance money adminAbout 15 minutes

Merge a year of monthly CSV exports into one file with Claude Code

Many banks and payment apps let you export one month at a time. Copying twelve files into one spreadsheet by hand is slow, and the mistakes are easy to miss: a month pasted twice, a bank that changed its column layout halfway through the year, or an export that runs a few days into the next month. This lesson gives you one instruction for Claude Code that checks the files first, merges them with a small script you can reuse, and shows that the totals still add up.

What you will be able to do: turn a folder of monthly CSV exports into one clean file with the same columns, dates in one format, overlap rows removed and listed, and a check table that shows nothing was lost. Your original files are only read, never changed.

Why use Claude Code for this, not a chat window

You could paste twelve files into an AI chat and ask for one table back. The trouble is that a chat assistant retypes your numbers, and a single wrong digit is hard to spot in 200 rows. Claude Code works on the files in a folder on your computer. Instead of retyping your data, it writes a short program that reads the files and does the arithmetic. That gives you three things a chat window does not:

Only have one file and a question about it? Upload a CSV file to Claude and check every answer shows how to do that in a chat, with code execution turned on.

What you need

Before you start

The steps

  1. Open your terminal and go to the new folder, for example cd ~/money-2025.
  2. Type claude and press Enter to start Claude Code.
  3. Paste the instruction below and press Enter.
  4. Claude Code looks at the files and describes them. Read the plan. Check that it found every file and that "money in is positive" is true for each layout. Correct anything that is wrong.
  5. Reply go. If Claude Code asks to create and run merge_exports.py, approve it.
  6. Read the check table. Every difference between "rows read" and "rows in merged" should have a reason you agree with.
  7. Open merged/all-transactions.csv and spot-check three rows against your bank's own statement.

The instruction

Copy it as it is. If your folder is not called exports, change the first line.

Copyable instruction for Claude Code
The folder exports/ holds my monthly bank export CSV files. I want one combined file. Do not change, move or delete the original files.

Step 1. Look before you change anything:
- List every CSV file with its row count and column headers.
- Tell me if the files do not all use the same columns, date format or amount format.
- Show how you will map every file to these columns: date, description, amount, source_file. Money in is positive, money out is negative.
Then stop and wait for me to reply "go".

Step 2. After I reply "go":
- Write a Python script called merge_exports.py that does the merge, then run it.
- Write dates as YYYY-MM-DD and sort the rows by date, oldest first.
- If exactly the same row (same date, description and amount) appears in two different files, keep one copy and list every row you removed. Keep repeated rows that appear within the same file, because they can be real.
- Save the result as merged/all-transactions.csv.

Step 3. Check your work and show a short table:
- Rows read from each file, rows in the merged file, and the reason for any difference.
- The total of the amounts in each source file, compared with the total of the rows from that file in the merged file.
- The first and last date in the merged file.
Tell me anything you were unsure about.

Worked example

We ran this instruction with Claude Code on 21 October 2026. The bank files are made up for illustration: twelve monthly exports for 2025 (229 rows) with four traps built in.

After Step 1 (excerpt, as returned)

Claude Code found both layouts before changing anything:

The two layouts Claude Code reported. On a phone, scroll the table sideways.

LayoutJan–JunJul–Dec
ColumnsDate, Description, Debit, CreditTransaction Date, Details, Amount (SGD)
Date formatDD/MM/YYYYDD Mon YYYY
AmountTwo columns, both positive; commas in thousandsOne signed column; no thousands separators

It also noticed the overlap ("2025-03.csv ends with two April rows, and both also appear in 2025-04.csv"), noted the byte-order mark, and said it would keep both May coffees because they come from the same file. Then it stopped and waited for "go".

After Step 3 (as returned, shortened to the changed rows)

Check table. The full table listed all 12 files; the other 11 matched exactly. On a phone, scroll the table sideways.

FileRows readRows in mergedSource totalMerged totalDifference
2025-0419174,371.942,563.941,808.00
All 12 files22922782,091.5480,283.541,808.00

Claude Code explained the difference: it removed two rows from the April file because identical rows were already in the March file (2025-04-01, MOBILE PLAN, -42.00 and 2025-04-02, CLIENT PAYMENT AGENCY B, 1,850.00), and "the 1,808.00 difference in April is exactly those two rows (1,850.00 − 42.00)." The first date was 2025-01-01 and the last 2025-12-31.

Under "things I was unsure about", it raised fair points: it assumed day-first dates because 13/01/2025 cannot be month-first; the January to June files had no currency label, so it assumed SGD; and the two removed rows could, in theory, be real repeat payments. That last one is your call: check your statement if you are not sure.

What we checked: we wrote our own separate script to merge the same files and compared the results. Claude Code's file had the same 227 rows and amounts, in date order, with both May coffees kept. Checksums of the twelve original files were identical before and after, so nothing was changed.

Watch out for

Next month: run the script again

Add the new month's file to exports, then run python3 merge_exports.py in the folder, or ask Claude Code to run it and show the check table again. We tested what happens when a new file has a layout the script has not seen: the script Claude Code wrote for us stopped with an "unrecognised columns" message and wrote nothing, instead of guessing. Your script may be written differently, so ask Claude Code to confirm it does the same. If it stops, ask Claude Code to add the new layout.

Next step

How we checked this lesson