Compare two small CSV files by ID and check the changes
Compare two tiny csv exports, using ID, with RowSlice. Use the practice files to find out which rows are added, deleted, modified, as well as see if there are any empty or duplicate IDs.

In short
- Use free RowSlice tool: Compare Two CSV Files (opens in a new tab) to compare based on stable ID, order may vary. No login required.
- For each ID, make sure all IDs are covered in both files. Be prepared to stop if you find blank or duplicate ID. (or missing records in preview)
- Begin with exact text, Review added, removed, and changed records. Then reconcile numbers. Even if you get 0 rows left out, it's possible that you have a blank ID.
We will demonstrate with fictional stationery, 5 rows each. (use small non-sensitive files with same headers and unique ID per record. keep originals) RowSlice claims to do all the processing in browser (opens in a new tab). It's their privacy statement, not security audit.
1. Open the practice files
- Grab the ZIP with practice files then extract. (That's old.csv, new.csv, blank/dup ID practice files, and the answer key)
- Head to RowSlice's compare tool (opens in a new tab). Click on the Browse Files button. Pick old.csv and new.csv.
- Confirm the Old file and New file labels. (Swap Old/New if needed.) Removed/Added is from the new file's perspective.
The example data has identical 3 headers in both files: ID, Item and Amount. Amounts are made-up with no currency. There are 5 records in each file (not including the header).
2. Read every ID before you compare
Watch out
A successful compare does not "verify" your IDs. You should review both full previews before you click on Compare Files. If you have a record with no ID or if you have a duplicate ID in either file, or if you can't account for all the records, stop right there. Fix it with reference to the original source.
- Read the ID downward for old file preview. 0001 0002 0003 0004 0005
- Read the ID downward for new file preview. 0005 0002 0001 0006 0004
It's not the same order, but all ID still refer to a single record.
- You should see 5 records in the preview. All records have non blank ID. All individual ID show up exactly one time in the preview file. All leading 0 are kept. (For your files, try to match the preview number of records to the total record number in source export.)
A record with ID need to be the same between exports. You cannot use a row number that changes when sorting the file. This manual process is only for files that are small enough to check. It will not catch all invisible character in an ID.
For practice of seeing issues; Choose Different Files. For duplicate-old.csv with new.csv. Find both of ID 0002 in six row old preview. For blank-old.csv with new.csv. Find empty ID in sixth old record. [Just for preview for both.] Don't create ID and delete legit record to remove warning. After that, back to old.csv with new.csv for the rest.
3. Compare the exact text
- Under 'Match rows on' check only 'ID'
- Under 'A row counts as changed when' choose 'any other column is different'
- Do not check 'Ignore upper and lower case' or 'Ignore spaces at the start and end of values'.
- Click 'Compare Files'
The clean version gets 1 added, 1 removed, 2 changed and 2 unchanged. The RowSlice keeps leading zeros in the previews. And also in IDs when downloaded, like 0002. And the comma in Notebook, blue in Item.
4. Check the records, then the counts
Read What changed?
To see the difference between the original files and answer key:
New item 0006 Lamp is added
item 0003 Folder is deleted
item 0002 "Notebook, blue" Amount is changed from 12.50 to 13.00
item 0004 Item is changed from "Pen" to "Pen " (one space after the word)
item 0001 and 0005 are not changed.
The space after the Pen. When you look at it on the screen it's easy to overlook. Exact compare will treat it as a change. Use the Ignore spaces at start and end of values option if you don't care about the spaces. So if you run your sample through again with that option you'll get 1 changed & 3 unchanged. But you'll still have one that's added and one that's removed. The RowSlice option also affects matching keys (opens in a new tab) according to RowSlice. So double-check your IDs before you start using it with your files. If you try that option then uncheck it and re-run old.csv against new.csv before continuing to below.
Make sure you've got the correct totals. For a valid one ID per record comparison.
Old file: 1 removed + 2 changed + 2 unchanged = 5 records.
New file: 1 added + 2 changed + 2 unchanged = 5 records.
The totals can give you a count difference. But that doesn't mean you're complete in your exports nor are you guaranteed to have the correct values. You also want to read each of the changed values.
Watch out
If Rows left out >0 Then stop and look at the duplicate IDs. RowSlice only compares the first instance of a duplicate key. Subsequent duplicate key instances are ignored. Rows left out can be zero, but zero by itself is not proof of validity of all the IDs. For example the blank IDs in the guide's example gave a Rows left out=0 value even though it reported the unidentified record as deleted.
5. Download and inspect the results
Download All as Zip and decompress. For this example, you will get 4 files.
new-added.csv - 0006
old-removed.csv - 0003
new-changed.csv - new values of 0002 and 0004
old-changed-before.csv - old values of 0002 and 0004
For changed files, keep them side by side with before files. Compare them by ID. Note there is no unchanged-row file in the download. 0001 and 0005 are the same in both original files.
If you need precise look at leading zeros/quotes/trailing space, then open them in a text editor like csv file. Import them into spreadsheet if you want, but ID should be kept as text and you must verify it after import. You don't get a comparison report that tell you which is correct or do any merge for you.
If the result looks wrong
- almost all addition and removals, make sure the ID you selected is stable and old and new files are the right ones
- missing or changed name column, stop your walkthrough and fix the export headers at the source (don't assume they did compare unpaired columns)
- warning (or mismatching count or file part out of preview), please save original files and fix your input, before you use the report - this small file manual check is not a large file validation method
Sources: RowSlice comparison instructions (opens in a new tab), privacy statement (opens in a new tab), terms of use (opens in a new tab).
Share this post
From holdmytwist.com/blog/compare-small-csv-files-by-id/

