SPARKPOND / GUIDE

How to Compare Two CSV Files by a Key

A stable key lets rows move without looking changed and connects old and new versions for field comparison.

Problem symptoms

  • Row-by-row diffs report many false changes.
  • You need an audit of a supplier update.

Why it happens

  • Rows were sorted differently.
  • Records were added or removed.
  • One field changed under the same identifier.

Example before and after

Before

old: A,10 / B,20
new: A,12 / C,30

After

changed A / removed B / added C
Download example ↓

Procedure

  1. Choose a unique stable key.
  2. Resolve duplicate keys.
  3. Select compared columns.
  4. Review and export change groups.
Compare Two CSV Files Online →

Common mistakes

  • Using row number as identity.
  • Ignoring duplicate keys that multiply matches.

Other possible solutions

  • Use a version-control diff for small, consistently sorted text files.

Important limitations

  • No reliable key means some matches remain ambiguous.

Related guides

How to Merge CSV Files with Different Columns

Files can be merged when their headers are mapped to a common output schema rather than matched by position.

How to Remove Duplicate Rows from a CSV

Duplicates must be defined by all columns or by stable business keys before rows are removed.