Caltech Library logo




csvrows converts a set of command line args into rows of CSV formated output. It can also be used to filter or list specific rows of CSV input The first row is 1 not 0. Often row 1 is the header row and %!s(MISSING) makes it easy to output only the data rows.


Below are a set of options available.

    -d, -delimiter        set delimiter character
    -examples             display example(s)
    -generate-manpage     generate man page
    -generate-markdown    generate markdown documentation
    -h, -help             display help
    -header               display the header row (alias for '-rows 1')
    -i, -input            input filename
    -l, -license          display license
    -o, -output           output filename
    -quiet                suppress error messages
    -random               return N randomly selected rows
    -row, -rows           output specified rows in order (e.g. -row 1,5,2-4))
    -skip-header-row      skip the header row (alias for -row 2-
    -trim-leading-space   trim leading space in field(s) for CSV input
    -use-lazy-quotes      use lazy quotes for CSV input
    -v, -version          display version


Simple usage of building a CSV file one rows at a time.

csvrows "First,Second,Third" "one,two,three" > 4rows.csv
csvrows "ein,zwei,drei" "1,2,3" >> 4rows.csv
cat 4row.csv

Example parsing a pipe delimited string into a CSV line

csvrows -d "|" "First,Second,Third|one,two,three" > 4rows.csv
csvrows -delimiter "|" "ein,zwei,drei|1,2,3" >> 4rows.csv
cat 4rows.csv

Filter a 10 row CSV file for rows 1,4,6 (top most row is one)

cat 10row.csv | csvrows -row 1,4,6 > 3rows.csv

Filter a 10 row CSV file for rows 1,4,6 from file named “10row.csv”

csvrows -i 10row.csv -row 1,4,6 > 3rows.csv

Filter 3 randomly selected rows from 10row.csv rendering new CSV with a header row from 10row.csv.

csvrows -i 10row.csv -header=true -random=3

csvrows v0.0.25