Tool to diff CSV files at the field level?

Try git diff:

git diff --color-words="[^[:space:],]+" x.csv y.csv

git diff --word-diff-regex offers a way to show changes at the field level. See Also use comma as a word separator in diff

This solution works well for showing changes in a CSV file with numbers and no spaces. For example, suppose we changed one number

 1,1,1,1,1,1,1,1

to

 1,1,2,1,1,1,1,1

If we use git diff --word-diff-regex="[^[:space:],]+" x.csv y.csv, then we get:

 1,1,[-1-]{+2+},1,1,1,1,1

This can be very helpful for a CSV file with many columns.


csvdiff is a command-line tool written in Python that compares CSV files on the field level: https://pypi.python.org/pypi/csvdiff

Tags:

Csv

Diff