A small utility for manipulating CSV files.
csvslim
is a small program that allows you to manipulate CSV files. It includes the following features:
- Filter columns out.
- Renaming columns.
- Filtering rows.
$ go build csvslim.go
# OR
$ make build
$ go install
# OR
$ make intall
csvslim [FLAGS] < input.csv
csvslim
supports the following flags:
-c COLUMN1,COLUMN2,...
: Shows only the entered columns.-i COLUMN1,COLUMN2,...
: Removes entered columns from the output.-r "COLUMN1:NAME1,COLUMN2:NAME2,..."
: Renames columns on the first line.--noheader
: Removes the first line from the output.--filter FILE
: Filters the input using the values withinFILE
. By default, values on the input file are compared with the ones listed on the first column.--filtercol COLUMN
: Specify the column number holding the values that should be compared against the ones on the filter file.--inverse
: Inverts filtering condition.
Both -c
and -i
support including a comparison operator for removing columns within an interval.
csvslim -c 1,3 < input.csv
csvslim -c "<3,4" < input.csv
csvslim -c "<1,4>" < input.csv
csvslim -r "0:Code,2:Retail Price" < input.csv
csvslim --filter filter.csv < input.csv
csvslim --filter filter.csv --inverse < input.csv
csvslim --filter filter.csv --filtercol 1 < input.csv
Licensed under MIT License.