Some tools for working with and analysing CSV files, including:
csvproject: project columns from a CSV filecsvreport: output a report for each column showing the type of data, number of empty values, and so on.
Here’s an example input file:
# test.csv:make,model,derivativeford,capri,2.0Lford,capri,3.0Lcitroen,ds,2.3LProject as in projection. Select and output columns from the input file.
$ csvproject test.csv -c makefordfordcitroen
$ csvproject test.csv -c make -c derivativeford,2.0Lford,3.0Lcitroen,2.3L
$ # exclude columns instead of including:
$ csvproject test.csv -e modelford,2.0Lford,3.0Lcitroen,2.3L
$ csvproject test.csv -c model --headers-outmodelcapricaprids
$ csvproject test.csv -c 1 --no-headersmodelcapricaprids
$ # here's an example using stdin:
$ csvproject -c make < test.csvfordfordcitroen
$ # use a tab delimiter:
$ csvproject -d$'\t'< test.tsvford,capri,2.0Lford,capri,3.0Lcitroen,ds,2.3LGenerate a report showing the range and type of values for each column selected
$ csvreport test.csv -c makeColumn: make┌────────────────────┬────────────────────────────────────────────────────────────┐│ Type │ String │├────────────────────┼────────────────────────────────────────────────────────────┤│ count │ 3 │├────────────────────┼────────────────────────────────────────────────────────────┤│ min │ citroen │├────────────────────┼────────────────────────────────────────────────────────────┤│ max │ ford │├────────────────────┼────────────────────────────────────────────────────────────┤│ minLength │ 4 │├────────────────────┼────────────────────────────────────────────────────────────┤│ maxLength │ 7 │├────────────────────┼────────────────────────────────────────────────────────────┤│ Unique strings (2) │ ford, citroen │├────────────────────┼────────────────────────────────────────────────────────────┤│ emptyCount │ 0 │└────────────────────┴────────────────────────────────────────────────────────────┘- Write usage docs.
- Support files without a header row.
- Support input from stdin.
- Write some tests.
- Add flag to exclude columns instead of including.
- Improve test coverage.
- Support passing options from a config file.