File tools · CSV

Compare two CSV files row by row, by key.

Find which records were added, removed or changed between an old and a new export. Rows are matched on a key such as an ID, so a re-sorted file does not show up as a wall of differences.

Key-based, not line-based: pick the column that identifies a record, and the tool reports what is only in A, only in B, and which cells differ.

Why compare by key

A plain text diff compares line against line. Re-sort a CSV, or add one row near the top, and every following line looks different. This page instead matches rows by the key column you choose, so the question it answers is the useful one: which records exist only in the old file, which only in the new one, and for the records in both, which cells changed.

Columns are matched by header name, not by position, so files whose columns come in a different order compare correctly. Columns that exist in only one file are listed and left out of the cell comparison, but they still appear in the differences file so you can see them.

Your files stay on your device

Both files are held in this tab’s memory and nowhere else. The sandboxed frame cannot make network requests, and the advertising on this page sits outside the frame where it cannot read anything inside it. Comparing a payroll export or a customer list with last month’s version is a good reason not to give either to an online service.

Reading the result

The summary counts rows only in A (removed), only in B (added), in both with different values and in both and identical. Changed cells are listed with the key, the column, and the value in A and in B. The downloadable differences file is one wide table: a first column _change says removed (only in A), added (only in B), changed: A value or changed: B value, followed by every column. Changed rows appear as an A line and a B line one under the other, so a spreadsheet filter on _change gives you the review list.

Worked example

Both files have the columns id and qty. File A has ids 1 to 4 with a qty of 5, 7, 9 and 1. File B has ids 1, 2, 4 and a new id 5, with quantities 5, 8, 1 and 2, and one extra column extra. Keyed on id the result is: id 3 removed, id 5 added, id 2 changed (qty 7 to 8), ids 1 and 4 identical, and extra reported as a column only in B. Had the two files simply been diffed as text, the extra column and the changed order would have flagged every line.

Common mistakes

What this tool does not do

It does not apply numeric tolerances, understand dates, match renamed columns or renamed keys, or compare more than two files. It does not read Excel workbooks. To compare two simple lists of values use compare two lists.

Frequently asked questions

Are my files uploaded to compare them?

No. Both files are parsed in your browser tab and compared there. The tool runs in a frame that cannot send network requests.

What is the key column?

The column, or combination of columns, that identifies the same record in both files, such as an order ID or an email address. Rows with the same key are compared cell by cell.

Does column order matter?

No. Columns are matched by header name, ignoring case, so a file with the same columns in a different order compares correctly.

What if a key appears more than once?

Only the first row with each key is compared in each file, and the result tells you how many extra rows were skipped. Use more key columns or remove the duplicates first.

Are 1.5 and 1.50 treated as equal?

No. Values are compared as text after the trim and case options. Normalise numbers and dates in both files first if the formats differ.

Can I ignore a column that always changes?

Yes. Tick it under the ignore list, for example an updated_at timestamp, and it is left out of the cell comparison.

What does the differences file contain?

One table with a _change column and all the columns: removed rows from A, added rows from B, and for changed records both the A and the B version.

Sources

Exact text comparison

This page reports differences in text. It does not judge whether a difference matters, and it cannot detect a record whose key was edited.

Advertisement
Advertisement