Skip to main content

Generate a diff between two CSV files.

Project description

https://badge.fury.io/py/csvdiff.png https://travis-ci.org/larsyencken/csvdiff.png?branch=master https://pypip.in/d/csvdiff/badge.png

Overview

Generate a diff between two CSV files on the command-line.

Installing

pip install csvdiff

Examples

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.

License

BSD license

History

0.1.0 (2014-03-15)

  • 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

csvdiff-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

csvdiff-0.1.0-py2.py3-none-any.whl (6.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file csvdiff-0.1.0.tar.gz.

File metadata

  • Download URL: csvdiff-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for csvdiff-0.1.0.tar.gz
Algorithm Hash digest
SHA256 19f8304b464514ede58f56c4b7a6e10dbb5bdffc14ccadeb0e2380da5d6eb08d
MD5 8cf4d6a02bdb425f04a6bea40eacfa25
BLAKE2b-256 233fc9a9553a0d3376c20f7442e19e80874eecf3d5e3b4c228bda38239718003

See more details on using hashes here.

File details

Details for the file csvdiff-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for csvdiff-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e0c76251ce5bd0caca1d6d531d0c725e4eaa8206ffb9342e591854a215124c8a
MD5 d8b5c6d1d573145ebe06ae2f2c7d7465
BLAKE2b-256 dcfe1095a2fbb9c32132aa1792b2a86789579cdbf1e48e1ff3c546a615f1cd6d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page