How to Compare Two CSV Files

How to Compare Two CSV Files - Rons Data Compare


Two exports of the same customer list, last month's price sheet and this month's, an inventory file before and after an update: sooner or later you need to know exactly what changed between two CSV files. This guide shows how to do it with Rons Data Compare, step by step, and how to choose between matching rows by their order and matching them by a key column.

Why Not Just Use a Text Compare or Excel?

A CSV file is a table, but a text compare tool sees it as lines of text. That works while both files keep the same rows in the same order. As soon as one export is sorted differently, has a few rows inserted, or has an extra column, a line-by-line compare reports almost every line as changed.

Comparing in Excel has its own problems: you have to build lookup formulas, and Excel may change values on the way in (leading zeros, dates, long numbers). See How to Keep Leading Zeros and Dates When Opening a CSV File.

Rons Data Compare compares the data itself:

  • columns are matched by name or position, even if they are in a different order
  • rows are matched by their order, by all mapped columns, or by one or more key columns such as a customer number or an email address
  • differences are shown for whole columns, whole rows and single cells
  • you can copy changes from one file to the other, then save

Your files are opened and saved on your own computer; there is no account and no cloud.

What You Need

  • Rons Data Compare: download and install it. The free Lite edition has every compare and update feature and saves files of up to 2,500 rows.
  • The two files. Any delimited text file works: CSV, TSV, PSV and other delimiters, detected automatically.

Step 1 – Open the Two Files

  1. Click New Comparison. A new comparison opens in its own tab with an empty left and right side.
  2. Open the older (or "reference") file on the left and the newer file on the right.

You can also use the Locations panel to browse to your files: right-click a file and choose Open Comparison to start a comparison with that file on the left, or Send Left / Send Right to place it on one side of the current comparison.

Step 2 – Map the Columns

Rons Data Compare needs to know which columns in the two files hold the same data.

  • Click Auto Map and choose Build Map from Names (the default) to pair columns with the same heading, or Build Map from Positions to pair the first column with the first, and so on.
  • Check the Columns Mapped list and add, edit or remove pairs if a column was renamed between the two files.

Columns that are not mapped are still shown, but they are not used to match rows.

Step 3 – Choose How Rows Are Matched

This is the most important choice.

Your files Use How it works
Same rows in the same order, with a few rows added or removed Match Sequential (the default) Walks both files from top to bottom and looks ahead to absorb inserted or deleted rows.
Each row has an ID, code, email or other unique value A Match Key mode Rows are paired by the key columns, whatever their order. The other mapped columns are compared cell by cell.
No unique value, order not reliable Match full row Rows are paired when all mapped columns are equal. You see which rows are on one side only, but not which cells differ.

Comparing by a Key Column

If your files have a unique value per row, a key is almost always the best choice. In the Columns Mapped list, select the column (for example Customer ID) and click Make Key Column. You can select more than one column for a combined key, such as Order number plus Line number.

Then pick one of the key modes:

  • Match Key – Left and right: every row from both files is shown. Use this to see what was added, removed and changed.
  • Match Key – Left only: every row from the left file, plus the matching rows from the right.
  • Match Key – Lookup: looks up a matching right-hand row for each left-hand row.

If you choose a key mode without making a key column, the compare falls back to Match Sequential.

Options

  • Use Case – treat upper and lower case as different.
  • Ignore space and symbols – ignore spaces and symbols when matching.
  • Conversion Region – the regional settings used when values are compared.

For more detail, see Data Compare Row Comparison Explained.

Step 4 – Compare and Review

Click Compare. Both files switch to Compare View, an overlay on top of the two documents. Nothing in your files changes until you apply an update.

  • Green – a column, row or value that exists only on this side
  • Red – the matching gap on the other side, where a row or value is missing
  • Purple – a cell whose value is different in the two files

The Difference Summary shows how many column, row and cell differences were found. Use the navigation buttons to step through columns, rows and cells separately, and keep the two grids aligned with scroll lock while you read. You can search, replace and sort while you review.

Step 5 – Update One File from the Other (Optional)

If you only wanted to see what changed, you are done. If you want to bring one file up to date, use the Actions panels on either side of the Differences tab:

  • Columns – add an extra column to the other file (with or without its values), or delete it
  • Rows – add missing rows (filled, key only or empty), delete extra rows, or delete rows that are the same in both files
  • Cells – copy missing values, update cells that differ, or clear them

Actions work on your selection or on the whole file, and in either direction. Each file has its own undo and redo, so you can step back on one side without touching the other. When you are happy, save the file you changed.

Click Clear to remove the comparison overlay and return to the normal view.

Tips

  • With Match Sequential, sort both files the same way first if their rows are not already in a comparable order.
  • Keep the original exports. Work on copies if you plan to apply updates.
  • Rons Data Compare Lite saves files of up to 2,500 rows; comparing larger files works, but saving them needs Rons Data Compare Pro, a one-time purchase of about US$17.50.

See Also