Skip to main content
GuideBest practicesBeginner

Compare two CSV or Excel files and identify the differences

Learn how to compare two versions of a table using a stable key and distinguish added, removed and modified records.

Published 29 August 2026Reading : 2 minBy Yann Bastien
Show contents
  1. Choose a comparison key
  2. Row numbers are usually a poor key
  3. Added, removed and modified records
  4. Normalize before comparing
  5. Check duplicate keys

Comparing tables is common: yesterday’s export versus today’s, inventory before and after a change, or data from two different systems.

The main challenge is not displaying two files side by side. It is deciding which row in file A corresponds to which row in file B.

Choose a comparison key

A key is a column that identifies a record, such as a customer ID, SKU or internal reference.

The Excel and CSV Comparator uses this logic to match records. For CSV-only work, CSV Compare offers a focused alternative.

Row numbers are usually a poor key

If a new row is inserted near the top of file B, every later position changes. A line-by-line comparison would report many false differences even though most records are unchanged.

A stable business key lets you compare records independently of their order.

Added, removed and modified records

A useful comparison distinguishes at least three situations:

  • a key exists only in the new file: added record;
  • it exists only in the old file: removed record;
  • it exists in both but other columns differ: modified record.

That distinction is much more informative than a simple “files are different” result.

Normalize before comparing

Whitespace, case differences or mismatched header names can create false positives. If both sources should follow the same conventions, clean them first.

See How to clean and prepare a CSV or Excel file for a practical sequence.

Check duplicate keys

Repeated keys do not overwrite rows: both comparators first match identical rows within each key group. They then pair remaining occurrences in their original order as changes; unmatched occurrences count as added or removed. This deterministic pairing does not prove that two occurrences represent the same business entity.

If the key should be unique, investigate repetitions before deleting anything. CSV Deduplicator creates a copy using an explicit rule; deduplication is not required for comparison.

Comparing before replacing a dataset is a useful safety step: understand what changed before accepting the new version.

In the spreadsheet comparator, put the older version under “Previous version” and the newer one under “New version”. Swapping the sources also reverses the meaning of additions and removals.

Was this article useful?