NAME
csvtool - command-line tools for operating on CSV-formatted data
SYNOPSIS
$ csvtool COMMAND OPTS... INPUT...
DESCRIPTION
This tool provides several named sub-commands that act similarly to UNIX commands of the same names, but operate on CSV-formatted data rather than simple lines of text.
Input is taken from one or more files named on the commandline, and output is printed to standard output using CSV formatting.
Columns in the data are named from 1 onwards. Thus, -f1
refers to the first column of data, -f2
the second, and so on.
COMMANDS
cut
$ csvtool cut -fFIELDS INPUT...
Extracts the given field column(s).
--fields, -f
A comma-separated list of field indexes (defaults to 1).
grep
$ csvtool grep PATTERN INPUT...
Filter rows by the given pattern. The pattern is always interpreted as a Perl regular expression.
--ignore-case, -i
Ignore case when matching.
--invert-match, -v
Output only the lines that do not match the filter pattern.
head
$ csvtool head -nLINES INPUT...
Output only the first few rows.
--lines, -n
Number of lines to output. If negative, will output all but the final few rows of the given number.
join
$ csvtool join -fFIELD FILE1 FILE2
Reads two files and outputs rows joined by a common key.
The second file is read entirely into memory and indexed by its key field. Then the first file is read a row at a time, and each row has the corresponding data from the second file appended to it when output.
--field1, -1
The field index in FILE1 to use as the lookup key.
--field2, -2
The field index in FILE2 to use as the storage key.
--field, -f
Use the same field index for both files.
sort
$ csvtool sort INPUT...
Sorts the rows according to the given field.
--field, -f
The field index to sort by (defaults to 1).
--numerical, -n
Sorts numerically. If absent, sorting happens alphabetically.
--reverse, -r
Reverses the order of sorting.
tail
$ csvtool tail -nLINES INPUT...
Output only the final few rows.
--lines, -n
Number of lines to output. If negative, will output all but the first few rows of the given number.
uniq
$ csvtool uniq -fFIELD INPUT...
Filters rows for unique values of the given field.
--field, -f
The field index to select rows on (defaults to 1).
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>