WIP CLI tool for working with csv files
Personal project for getting into golang.
- Produce diff.csv based specific columns from 2 files
- Cut some columns to output a smaller width csv file
- Shows stats on csv file like data type, null count, min/max/mean/sum
- Filter rows by applying regex pattern to given columns
- Produce multiple csv files grouped by given column values
- header-skip, header-restore for hassle free csv piping
go install github.com/zcag/ccsv@latest
Run ccsv --help
or ccsv [commmand] --help
for complete usage.
- All column flags can be either column index or header name
- All commands except diff can work with piped csv input or from a positional file argument.
Provides a csv with unique rows from left side, filtered by an arbitrary column.
ccsv diff -l 1 -r 4 left.csv right.csv
ccsv diff -l id -r user_id left.csv right.csv
ccsv diff -c id left.csv right.csv
Filter csv to show specified columns
ccsv cut -c 1 some.csv
ccsv cut -c id some.csv
cat some.csv | ccsv cut -c id -c 5 -c age
Show info about each column like data type, null count, uniq count, min/max/mean/summ
ccsv stat some.csv
ccsv stat -H headerless.csv
Strip headers and restore them later to easily work on csv files without touching header line
cat file.csv | ccsv header-skip | sort | ccsv header-restore
cat file.csv | ccsv hs | sort | ccsv hr
Filter rows by regex on specific columns
ccsv match -c name '\w+_\d' some.csv
cat some.csv | ccsv match -c email '.*@g?mail'
Create csv files grouped by specified column while preserving headers
ex. from customers.csv
you can get TR_customers.csv, EU_customers.csv etc.
ccsv group 'records_<country>' all_records.csv
cat some.csv | ccsv group '<3>_records_grouped'`,