Skip to main content
Bethemesh
GuideBest practices

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 Bethemesh Team
Beginner
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

If a supposedly unique key appears more than once, matching becomes ambiguous. Before an important comparison, verify uniqueness and use CSV Deduplicator where appropriate.

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

Related tools

Data & spreadsheets

Compare two Excel or CSV files

Compare two Excel or CSV files using a key column and spot the differences.

100% localFeatured
Use this tool
Data & spreadsheets

CSV Compare

Compare two CSV files to quickly identify rows and values that differ between them.

100% local
Use this tool
Data & spreadsheets

CSV Deduplicator

Remove duplicate CSV rows using the columns you choose as matching criteria.

100% local
Use this tool

Collection

Mastering data and tables

  1. 01Data and tables: understanding CSV, Excel, JSON and dataset structure
  2. 02How to clean and prepare a CSV or Excel file before using it
  3. 03Remove duplicates and validate CSV data without deleting the wrong rows
  4. 04Filter, sort, select and rename CSV columns efficiently
  5. 05Merge CSV or Excel files without misaligning columns
  6. 06Split a CSV or Excel table into smaller files
  7. 07Compare two CSV or Excel files and identify the differences
  8. 08Convert CSV, Excel, JSON and TSV without losing the structure
  9. 09Build a reproducible data-preparation workflow

Was this article useful?