How to Compare Two CSV Files by ID
Two exports can describe the same records in a different order. Match rows by a stable ID, such as a product SKU, and report changes by field. This produces a change list someone can check against the original exports.
Choose a stable key for each row
Look for a field that identifies a record in both files. In an inventory export it might be a SKU, or a SKU plus warehouse ID if the same product appears in several locations. Keep identifiers as text to preserve leading zeros.
Count blank or repeated keys in both files before comparing. Ask GRACE to flag those rows for review. A repeated key can create several plausible matches, so record the ambiguity until you have a rule to resolve it.
Define added, removed, and changed records
A new key appears only in the second export. A removed key appears only in the first. A changed record appears in both, with a different value in a field you care about. Decide whether trailing whitespace, case, and differently formatted dates should count as changes.
For an inventory comparison, report the SKU, change type, and before and after quantities. Leave the missing side empty for additions and removals. Keep zero as a quantity so a stockout stays distinguishable from a missing record.
Verify the change report against both files
The downloadable example has three rows per file. The report should contain exactly three changes. A-100 changed from 5 to 8, C-300 was added, and D-400 was removed. B-200 moved to a different line and its quantity stayed at 12.
Check at least one row of each change type against the source and reconcile the total counts. For the first file, the count equals unchanged plus changed plus removed. For the second file, replace removed with added.