csvsort
Type-aware CSV file sorter
TLDR
Sort by column
$ csvsort -c [column] [data.csv]
Sort descending$ csvsort -r -c [column] [data.csv]
Sort by multiple columns$ csvsort -c [col1,col2] [data.csv]
Sort numerically$ csvsort -c [amount] [data.csv]
Sort with no header$ csvsort -H -c [1] [data.csv]
Read from stdin$ cat [data.csv] | csvsort -c [name]
SYNOPSIS
csvsort [options] file
DESCRIPTION
csvsort sorts CSV files by one or more columns. Part of csvkit, it properly handles CSV quoting and data types, detecting numeric and date values for appropriate sorting.
The tool maintains CSV structure during sorting, preserving headers and quoted fields correctly.
PARAMETERS
-c columns
Column(s) to sort by.-r, --reverse
Sort in descending order.-H, --no-header-row
Input has no header.-d char
Field delimiter.-q char
Quote character.-e encoding
Input encoding.-y n
Rows to sniff for type.
CAVEATS
Requires loading entire file into memory. Part of csvkit, needs Python. Type detection may not always match expectations. Large files can be slow.
HISTORY
csvsort is part of csvkit, created by Christopher Groskopf in 2011. The tool provides type-aware sorting that the Unix sort command cannot easily achieve with CSV data.
