Clean up a messy CSV export without fixing it by hand
The usual problems in exported CSV files (stray spaces, numbers stored as text, mixed dates, duplicates) and the spreadsheet formulas that fix each one in a way you can repeat next month.
Every system exports CSV, and almost every export needs work before you can total it: amounts with dollar signs that won't add up, dates in three formats, names with trailing spaces that break lookups, the same row twice. Fixing it by hand works once. Next month, you do it again.
The durable approach is to leave the export untouched and build a cleaned copy with formulas. Paste next month's export over the raw sheet and the clean sheet updates itself.
Set up two sheets
- raw: the export, exactly as downloaded. Never edit it.
- clean: one formula per column that reads the matching raw column and fixes it.
Every formula below is written for row 2 of the clean sheet; fill it down as far as the raw data goes.
Problem 1: stray spaces and invisible characters
Names that look identical but don't match in a lookup usually have a trailing space or a non-printing character.
=TRIM(CLEAN(raw!A2))
CLEAN removes non-printing characters; TRIM removes leading and trailing spaces and collapses double spaces inside.
Problem 2: numbers stored as text
Amounts like $1,250.00 or (45.00) are text, so SUM skips them without any error. Strip the symbols, then convert:
=VALUE(SUBSTITUTE(SUBSTITUTE(raw!C2, "$", ""), ",", ""))
Some exports write negatives in parentheses. Handle both:
=IF(LEFT(raw!C2) = "(", -1, 1) * VALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(raw!C2, "$", ""), ",", ""), "(", ""), ")", ""))
Check the result: =COUNT(clean!C:C) should equal the number of data rows. If it's lower, some values still didn't convert.
Problem 3: dates as text, in mixed formats
A date column with 2026-07-03, 07/03/2026 and Jul 3, 2026 won't sort or group. If the export uses one consistent format that your spreadsheet doesn't recognize, rebuild it from its parts. For 07/03/2026 (month first):
=DATE(RIGHT(raw!A2, 4), LEFT(raw!A2, 2), MID(raw!A2, 4, 2))
For mixed formats, fix the most common one with a formula and list the exceptions with a check column: =ISNUMBER(clean!A2) is FALSE wherever the date didn't convert.
Problem 4: duplicates
First decide what makes a row unique: often a transaction ID, or a date, amount and description together. Then count how many times each appears:
=COUNTIFS(raw!A:A, raw!A2, raw!B:B, raw!B2, raw!C:C, raw!C2)
Anything above 1 is a candidate duplicate. Look before deleting. Two identical coffee purchases on the same day can both be real; two identical invoice numbers usually aren't.
Problem 5: one column that should be two
A "Name" column like Lee, Jordan splits at the comma:
Last name =LEFT(raw!B2, FIND(",", raw!B2) - 1)
First name =TRIM(MID(raw!B2, FIND(",", raw!B2) + 1, 100))
Count rows at every step
Cleaning should never lose data silently. Keep a small checks block at the top of the clean sheet:
Rows in raw =COUNTA(raw!A:A) - 1
Rows in clean =COUNTA(clean!A:A) - 1
Amounts that convert =COUNT(clean!C:C)
Total, raw vs clean =SUM(clean!C:C)
Compare the clean total with the export's own total, if the source system shows one.
Doing it with Jordan
Import the CSV and ask: "Clean up this export on a new sheet: trim the names, convert the amounts and dates, and flag likely duplicates. Leave the raw sheet untouched and add a checks block comparing row counts." Jordan writes the cleaning formulas and shows you every change as a changeset. Because the cleaning is formulas, next month's export goes through the same steps.
Frequently asked questions
Why not clean the data in place?
Because you can't repeat it, and you can't check it. A formula on a separate sheet shows exactly what changed, and works on next month's file.
My numbers still won't add up after VALUE. Why?
Look for a non-breaking space (common in exports from web apps). Add SUBSTITUTE(raw!C2, CHAR(160), "") inside the formula.
How do I handle an export that changes its columns?
Look up columns by header instead of position: =INDEX(raw!A:Z, ROW(), MATCH("Amount", raw!1:1, 0)) reads the column named Amount wherever it is.