csvsort1
Csvsort documentation
Overview
Sort CSV files. Like the Unix "sort" command, but for tabular data:
usage: csvsort [-h] [-d DELIMITER] [-t] [-q QUOTECHAR] [-u {0,1,2,3}] [-b][-p ESCAPECHAR] [-z FIELD_SIZE_LIMIT] [-e ENCODING] [-L LOCALE][-S] [--blanks] [--null-value NULL_VALUES [NULL_VALUES ...]][--date-format DATE_FORMAT] [--datetime-format DATETIME_FORMAT][-H] [-K SKIP_LINES] [-v] [-l] [--zero] [-V] [-n] [-c COLUMNS][-r] [-i] [-y SNIFF_LIMIT] [-I][FILE]Sort CSV files. Like the Unix "sort" command, but for tabular data.positional arguments:FILE The CSV file to operate on. If omitted, will acceptinput as piped data via STDIN.optional arguments:-h, --help show this help message and exit-n, --names Display column names and indices from the input CSVand exit.-c COLUMNS, --columns COLUMNSA comma-separated list of column indices, names orranges to sort by, e.g. "1,id,3-5". Defaults to allcolumns.-r, --reverse Sort in descending order.-i, --ignore-case Perform case-independent sorting.-y SNIFF_LIMIT, --snifflimit SNIFF_LIMITLimit CSV dialect sniffing to the specified number ofbytes. Specify "0" to disable sniffing entirely, or"-1" to sniff the entire file.-I, --no-inference Disable type inference (and --locale, --date-format,--datetime-format, --no-leading-zeroes) when parsingthe input.
See also: Arguments common to all tools.
NOTE:
If your file is large, try sort -t, file.csv instead.
Examples
Sort the veteran's education benefits table by the "TOTAL" column:
csvsort -c 9 examples/realdata/FY09_EDU_Recipients_by_State.csv
View the five states with the most individuals claiming veteran's education benefits:
csvcut -c 1,9 examples/realdata/FY09_EDU_Recipients_by_State.csv | csvsort -r -c 2 | head -n 5
Releases
4 releases since Debian 11 (Bullseye); the text changed 3 times.
--blanks until Debian 12 (Bookworm);
--columns until Debian 12 (Bookworm);
--date-format until Debian 12 (Bookworm);
--datetime-format until Debian 12 (Bookworm);
--delimiter until Debian 12 (Bookworm);
--encoding until Debian 12 (Bookworm);
--escapechar until Debian 12 (Bookworm);
--help until Debian 12 (Bookworm);
--linenumbers until Debian 12 (Bookworm);
--locale until Debian 12 (Bookworm);
--maxfieldsize until Debian 12 (Bookworm);
--names until Debian 12 (Bookworm);
--no-doublequote until Debian 12 (Bookworm);
--no-header-row until Debian 12 (Bookworm);
--no-inference until Debian 12 (Bookworm);
--quotechar until Debian 12 (Bookworm);
--quoting until Debian 12 (Bookworm);
--reverse until Debian 12 (Bookworm);
--skip-lines until Debian 12 (Bookworm);
--skipinitialspace until Debian 12 (Bookworm);
--snifflimit until Debian 12 (Bookworm);
--tabs until Debian 12 (Bookworm);
--verbose until Debian 12 (Bookworm);
--version until Debian 12 (Bookworm);
--zero until Debian 12 (Bookworm);
-H until Debian 12 (Bookworm);
-I until Debian 12 (Bookworm);
-K until Debian 12 (Bookworm);
-L until Debian 12 (Bookworm);
-S until Debian 12 (Bookworm);
-V until Debian 12 (Bookworm);
-b until Debian 12 (Bookworm);
-c until Debian 12 (Bookworm);
-d until Debian 12 (Bookworm);
-e until Debian 12 (Bookworm);
-h until Debian 12 (Bookworm);
-l until Debian 12 (Bookworm);
-n until Debian 12 (Bookworm);
-p until Debian 12 (Bookworm);
-q until Debian 12 (Bookworm);
-r until Debian 12 (Bookworm);
-t until Debian 12 (Bookworm);
-u until Debian 12 (Bookworm);
-v until Debian 12 (Bookworm);
-y until Debian 12 (Bookworm);
-z until Debian 12 (Bookworm).