Generate a diff between two CSV files.
Generate a diff between two CSV files on the command-line.
pip install csvdiff
For example, suppose we have a.csv:
id,name,amount 1,bob,20 2,eva,63 3,sarah,7 4,jeff,19 6,fred,10
and a matching file after some changes, b.csv:
id,name,amount 1,bob,23 3,sarah,7 4,jeff,19 5,mira,81 6,fred,13
Now we can ask for a summary of differences:
$ csvdiff --summary -k id a.csv b.csv 1 rows removed (20.0%) 1 rows added (20.0%) 2 rows changed (40.0%)
Or look at the full diff, using YAML rather than JSON (the default) to make it more readable:
$ csvdiff --yaml -k id a.csv b.csv removed: - amount: '63' id: '2' name: eva added: - amount: '81' id: '5' name: mira changed: - fields: amount: from: '10' to: '13' key: - '6' - fields: amount: from: '20' to: '23' key: - '1'
It gives us the full listing of added and removed rows, as well as a listing of what fields changed for that shared a key.
For more usage options, run csvdiff --help.
- First release on PyPI.
- Generates a JSON or YAML difference between two CSV files
- Specify multiple key components with -k
- Can provide a difference summary
- Assumes files use standard comma-separation, double-quoting and a header row with field names
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size csvdiff-0.1.0-py2.py3-none-any.whl (6.3 kB)||File type Wheel||Python version 2.7||Upload date||Hashes View|
|Filename, size csvdiff-0.1.0.tar.gz (6.6 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for csvdiff-0.1.0-py2.py3-none-any.whl