Why your CSV diff tool is lying to you (and how to fix it)
If you’ve ever diffed two CSV exports and gotten a wall of red, only to realize nothing actually changed — you’ve hit the same problem I kept running into. Most diff tools compare files line by line. That works fine for code, but it falls apart on tabular data the moment a single row gets inserted, deleted, or reordered anywhere in the file. Every row after that point shifts position, and a position-based diff reports all of them as “changed” — even though the underlying data is identical. Here’s a minimal example of the problem: File A id,name,status 1,Alice,active 2,Bob,active 3,Carol,pending File B (row 2 removed) id,name,status 1,Alice,active 3,Carol,pending The fix: match rows by identity, not position. I built a diff that detects a likely key column automatically (id, _id, key, slug, code, name — whatever’s actually present) and matches rows across both files by that value instead of line number. Reordering, insertions, and deletions stop generating noise. You see exactly three things: rows added, rows removed, and cells that genuinely changed on a row that exists in both files. The same principle applies to JSON and XML — array items get matched by a detected key field rather than array index, so reordering an array in an API response doesn’t produce a diff full of false changes either. That grew into a small toolkit: • Conversion — JSON↔CSV, JSON↔XML, flatten/unflatten nested structures • Diffing — JSON, CSV, XML, all key-aware as above • Schema tooling — generate a JSON Schema from a sample, validate data against one, or render it straight to a TypeScript interface or Zod schema • Access — a browser tool (nothing uploaded, runs entirely client-side), a CLI (npx recast-cli, works offline), and a GitHub Action for CI Free tier covers everything above with reasonable size limits — it’s at tryrecast.app if you want to try it on your own data. Curious whether others have hit this same reordering problem and what you used to work around it — Beyond Compare, a custom script, something else? Try it: http://tryrecast.app
This is a summary aggregated from Dev.to. Read the complete article on the original site:
Read full article at Dev.to