CSV Set Operations
Two lists, one question: what is in both, what is only in one. Paste an old export and a new one and take the difference; paste two mailing lists and take the union without duplicates; paste a list of active users and a list of paying ones and keep the overlap. Same idea as UNION, INTERSECT and EXCEPT in SQL, on files instead of tables.
CSV set operations
The operation people actually want when they say "compare two CSVs" is usually a set operation, not a diff: not what changed in this row but which rows are missing. This does the second one, and hands back a CSV you can use rather than a report you have to read.
How to use it
- Paste or drop file A on the left and file B on the right. Both need a header row.
- Pick the operation. The names in the list are the SQL ones; the descriptions next to them are what they do.
- Pick what to match on. Whole row means two rows are the same when every shared column matches. Pick a column instead — usually an
idor anemail— and only that column decides. - Read the status line. It reports how many keys were in both files and how many were on one side only, which is the answer to the question even before you look at the output.
- Copy or Download .csv.
The six operations
- Union — every row from both files, each one once. The result is A followed by the rows of B that A did not already have.
- Union all — every row from both files including duplicates. This is concatenation; merge files does the same for more than two.
- Intersect — rows that appear in both. The row emitted is A's copy, which matters when you matched on one column and the other columns differ.
- A minus B — rows in A that are not in B. This is the one people mean by "what is missing from the new export".
- B minus A — the other direction. Run both to see the two halves separately.
- Symmetric difference — rows in exactly one of the files. Equivalent to the two minus results stacked.
Matching, and why the column matters
With whole row selected, two rows are equal when every column the two files share has the same value. Columns that only one file has are listed in the status line and left out of the comparison — otherwise every row would differ for a reason that has nothing to do with the data.
Matching on a single column is nearly always what you want when the files come from different
systems. An export from billing and an export from the CRM will not agree about capitalisation,
trailing spaces, or a last_seen timestamp, but they agree about the email address.
Trim values and ignore case exist for the same reason:
"[email protected] " and "[email protected]" are the same customer and no
exact comparison will ever say so.
Duplicates
Every operation except union all emits each key once. If file A contains the same key three times, the intersection contains it once — a set has no multiplicities. When the duplicates are the point, find duplicates lists them with counts, and dedupe removes them in place.
Set operations or a diff?
Use this when the question is membership: which rows are in one file and not the other. Use CSV diff when the question is change: which cells of a matched row are different. The diff matches rows on a key and highlights the cells that moved; this hands you a file. They are answers to different questions and it is worth being clear which one you have.
For a genuine join — carrying the columns of B onto the matching rows of A — join on key is the tool. Intersect keeps A's columns only.
Privacy
100% client-side. Both files are parsed in your browser and nothing is uploaded. See the privacy policy.