Clean a messy CSV so Excel will open it cleanly

CSV is a simple format — commas, quotes, rows — but the files people actually receive are rarely simple. Exports from banks, shops, and form tools arrive with extra spaces, mixed date formats, amounts that are still text, duplicated rows, and the occasional cell that can make Excel do something you did not ask for.

Fix the mechanical mess first

Start with the things that should never have been in the file:

Remove only exact duplicate rows unless you are sure

An exact duplicate is every cell the same as another row. Those are safe to drop if you keep one copy. Near-duplicates — the same vendor and amount on the same day, with a slightly different description — might be two real charges. Do not collapse those automatically. Count how many exact rows you removed and make sure the money total moved by exactly that amount.

Watch for formula injection

Excel and other spreadsheet programs treat a cell that starts with =, +, -, or @ as a formula when they open a CSV. That is handy for a file you wrote on purpose. It is a problem when a CSV came from a form, a bank memo, or anyone else’s system. A description that begins with = can run a formula the moment you open the file.

The safe cleanup is simple: if a cell is not a plain number, and it starts with one of those characters, prefix a single quote. Excel then treats the cell as text. A value like -19.95 is a number and should stay a number. A value like -2+3+cmd is not a number and should be guarded. After you clean a file, search the text columns for those leading characters and confirm they now start with a quote.

A short before-and-after habit

Before you overwrite anything, note three figures from the messy file (or from a first pass): row count, sum of the amount column, and a couple of distinctive rows you can find later. After cleanup, those figures should still make sense. If you dropped 20 exact duplicates, the row count should fall by 20 and the total should fall only by the amount in those 20 rows. If a date failed to convert, it will still be in the old format — scan the column rather than assuming every cell changed.

TableWren’s cleanup tab runs those steps in your browser, shows a before-and-after preview, and writes a Totals Check sheet next to the clean data. The free download is capped at 100 cleaned rows; the full preview and the full totals are still shown so you can see whether the cleanup is right before you download.

What this will not fix

Cleanup will not invent a missing category, will not decide whether two similar charges are really one, and will not repair a CSV whose columns have slipped (a comma inside an unquoted description that shifts every field to the right). If the header row and the first data row do not line up, stop and fix the structure first. A tidy column of the wrong thing is worse than a messy column of the right thing.