Skip to content

Compare two CSV files for differences. Colorize the differences and align the columns. Forked from telnet23

License

Notifications You must be signed in to change notification settings

k4u5hik/pretty-csv-diff

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pretty CSV Diff

pretty-csv-diff is a Python utility that compares two CSV files for differences. It highlights these differences by colorizing them and aligning the columns for easy visual comparison. This tool is particularly useful for data analysts and developers who work with large datasets and need to quickly identify changes between two versions of a CSV file.

Features

  • Color-coded output for easy spotting of differences.
  • Column alignment for improved readability.
  • Command-line interface for easy integration with other tools or scripts.
  • Supports specifying multiple primary keys for comparison.

Installation

To install pretty-csv-diff, clone the repository and run the setup script:

git clone https://github.com/k4u5hik/pretty-csv-diff.git
cd pretty-csv-diff
pip install .

Usage

The basic command-line syntax for pretty-csv-diff is:

pretty-csv-diff [options] path1 path2 [primary_key ...]
  • path1 and path2 are the file paths to the two CSV files you want to compare.
  • primary_key is either the name or the index of the primary key column(s) in the CSV files. You can specify multiple columns for composite keys.

Example

To compare two CSV files old.csv and new.csv using the column id as the primary key:

pretty-csv-diff old.csv new.csv id

This will output the differences between the two files in your terminal, with < indicating rows that are only in old.csv and > indicating rows that are only in new.csv. Rows present in both files but with differences will be shown side by side for comparison.

Command-Line Example Screenshot

Command-Line Usage

usage: pretty-csv-diff [-h] path path pk [pk ...]

positional arguments:
  path        paths to the two csv files to be compared
  pk          name or index of primary key column. multiple columns are
              allowed

optional arguments:
  -h, --help  show this help message and exit

Contributing

Contributions to pretty-csv-diff are welcome.

License

pretty-csv-diff is released under the Apache License, Version 2.0 (January 2004). See the LICENSE file for more details.

About

Compare two CSV files for differences. Colorize the differences and align the columns. Forked from telnet23

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%