CSVSORT(1)

πŸ’– CSVSORT(1) πŸ’–

okay bestie, welcome to csvsort, part of the csvkit family πŸ‘‘


✨ NAME ✨

csvsort β€” literally just the csvsort Documentation, no cap 🫢


🌸 DESCRIPTION 🌸

It sorts CSV files. Like the Unix sort command, but make it tabular data ✨ Same energy, cuter payload πŸ’…

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 you wanna work on. Skip it and it'll happily take input as piped data via STDIN, slay πŸ¦‹

🧚 optional arguments

  • -h, --help β€” shows this help message and dips. iconic behaviour honestly ✨
  • -n, --names β€” shows you the column names and indices from the input CSV, then exits. a lil peek at the roster πŸ‘€
  • -c COLUMNS, --columns COLUMNS β€” a comma-separated list of column indices, names or ranges to sort by, like "1,id,3-5". defaults to all columns, so if you're indecisive it's got you πŸ’–
  • -r, --reverse β€” sorts in descending order. main character energy, biggest first 😀
  • -i, --ignore-case β€” does case-independent sorting. A and a are besties here, no drama 🌸
  • -y SNIFF_LIMIT, --snifflimit SNIFF_LIMIT β€” limits CSV dialect sniffing to that many bytes. say "0" to disable sniffing entirely, or "-1" to sniff the entire file. go big or go home fr fr πŸ’…
  • -I, --no-inference β€” disables type inference (and also --locale, --date-format, --datetime-format, --no-leading-zeroes) when parsing the input. it just takes everything at face value, no assumptions πŸ”₯

See also: Arguments common to all tools. (iykyk β€” all those other flags up in the usage line live over there πŸ‘‘)

NOTE: if your file is large, try sort -t, file.csv instead. fr, that's the move, don't fight it πŸ’€

🌈 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

πŸ’œ AUTHOR πŸ’œ

Christopher Groskopf and contributors 🫢


2016, Christopher Groskopf and James McKinney


and that's a wrap bestie πŸŽ€ this was csvsort, version 2.2.0, dated Aug 16, 2024, straight from the csvkit girlies. go sort something cute πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from