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:
- The numbers are copied by a program, not retyped by the model.
- The program is saved, so next month you can run it again in seconds.
- Claude Code can check its result against your original files and show you the comparison.
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
- Claude Code installed and signed in. New to it? Start with Getting Started with AI Coding on this site, or Anthropic's Claude Code quickstart. The quickstart lists the accounts you can use: a Claude subscription (Pro, Max, Team or Enterprise), a Claude Console account, or a supported cloud provider.
- Your monthly exports as CSV files. Many banks offer CSV as a download option. If yours only offers PDF statements, this lesson will not work as written.
- Python 3. Claude Code will write a small Python script. Type
python3 --versionin your terminal; if you see a version number, you are ready. If not, install Python from python.org first.
Before you start
- Work on copies. Make a new folder (for example
money-2025) and, inside it, a folder calledexports. Copy your CSV files intoexports. Keep the originals where they were. - Check what is in the files. The parts of your files that Claude Code reads are sent to Anthropic's model to be processed. If your exports contain full account numbers or other people's personal details, delete those columns from the copies first, and check your account's data settings.
- Read before you approve. Claude Code can create and run files in the folder you start it in. Depending on its permission settings, it asks before it edits files or runs commands. Read each request, and say no to anything outside your new folder.
The steps
- Open your terminal and go to the new folder, for example
cd ~/money-2025. - Type
claudeand press Enter to start Claude Code. - Paste the instruction below and press Enter.
- 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.
- Reply
go. If Claude Code asks to create and runmerge_exports.py, approve it. - Read the check table. Every difference between "rows read" and "rows in merged" should have a reason you agree with.
- Open
merged/all-transactions.csvand 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.
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.
- The "bank" changed its layout in July: from
Date, Description, Debit, Creditwith dates like13/01/2025, toTransaction Date, Details, Amount (SGD)with dates like03 Jul 2025and one signed amount. - The July to December files start with a hidden byte-order mark, an invisible character that can corrupt the first column name when a script reads the file.
- The March export runs to 2 April, so two April rows are in both the March and April files.
- May has two identical coffees on the same day. They are real and must be kept.
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.
| Layout | Jan–Jun | Jul–Dec |
|---|---|---|
| Columns | Date, Description, Debit, Credit | Transaction Date, Details, Amount (SGD) |
| Date format | DD/MM/YYYY | DD Mon YYYY |
| Amount | Two columns, both positive; commas in thousands | One 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.
| File | Rows read | Rows in merged | Source total | Merged total | Difference |
|---|---|---|---|---|---|
| 2025-04 | 19 | 17 | 4,371.94 | 2,563.94 | 1,808.00 |
| All 12 files | 229 | 227 | 82,091.54 | 80,283.54 | 1,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
- Dates that can be read two ways.
02/03/2025is 2 March in Singapore and the UK, but 3 February in the US. Make sure Step 1 says which one it chose, and why. - Money in and money out reversed. Some banks show spending as positive. Spot-check one known payment and one known expense in the merged file.
- Opening the result in a spreadsheet. Spreadsheet apps may reformat dates or drop trailing zeros when they open a CSV. That changes how it looks, not the file, unless you save over it.
- More than one account. Put each account in its own folder and run the lesson once per account, or ask for an extra
accountcolumn.
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
Categorise the merged file
With the whole year in one file, Lesson 1 shows how to sort it into categories, with uncertain rows flagged for you to check. If you would rather keep your income and expenses in Notion, the Notion Finance Dashboard product page lists an income and expense tracker, a budget and cash-flow views. The page shows what is included, the requirements and the price.
See what's inside the Finance DashboardMore lessons
Next: build a Notion income tracker that flags late invoices. Earlier this week: write a clear invoice and reminder, run a monthly cash review and build a tax set-aside habit.
All lessonsHow we checked this lesson
- The instruction was run with Claude Code 2.1.304 on 21 Oct 2026, on the illustrative files described above. We sent the instruction and then "go" as two messages in one conversation, using Claude Code's print mode (
claude -p, thenclaude -c -p "go"); typing them into an interactive session works the same way. Quoted outputs are as returned; the Step 3 table is shortened to the changed rows. - We verified the result with our own independent script: 229 rows read, 227 written, 2 cross-file overlap rows removed, totals and date order correct, the same-file repeat kept, and the original files unchanged (checksums).
- We also added a file with an unknown layout: the generated script stopped with an error and wrote no output.
- Install steps, sign-in and account options were checked against Anthropic's Claude Code quickstart on 21 Oct 2026. They can change; the official page is the authority.
- AI output varies. Your run may word things differently or keep a duplicate from a different file. Always read Step 1 and the check table before you rely on the merged file.
- Last reviewed: 21 October 2026.