Skip to content
Latchkey

xsv: Fast CSV select, search and stats

xsv is a Rust CSV toolkit whose subcommands (select, search, stats, frequency, headers) run fast on large files by streaming and indexing.

Where csvkit is feature-rich but Python-slow, xsv is built for speed on big CSVs. Each operation is a subcommand that streams the file.

What it does

xsv ships subcommands that each do one CSV job: select picks columns, search filters rows by regex, stats computes per-column statistics, frequency builds value counts, and headers lists columns. Most read stdin or a file and write CSV.

Common usage

Terminal
# list headers with indices
xsv headers data.csv
# select columns by name or 1-based index
xsv select name,email data.csv
# regex-filter rows on a column
xsv search -s status '^active$' data.csv
# per-column statistics
xsv stats data.csv | xsv table

Options

Subcommand / flagWhat it does
select <cols>Keep columns by name, index or range
search -s <col> <re>Keep rows where the column matches the regex
statsPer-column type, sum, mean, min, max, stddev
frequency -s <col>Frequency table for a column
headersList the header names
tableAlign CSV into a readable table
--no-headersTreat the first row as data, not a header

In CI

xsv handles CSVs too large for csvkit to load comfortably. Profile a big export with xsv stats huge.csv | xsv table, or assert a value exists with xsv search -s id "^42$" data.csv and check the exit/row count. Pipe stats through xsv table for a log-friendly summary.

Common errors in CI

xsv: command not found: install with cargo install xsv or a release binary. CSV error: ... found record with N fields, but the previous record has M fields means ragged rows; add --flexible. stats without an index is slower and single-threaded; build one with xsv index data.csv first. Note the original BurntSushi/xsv is in maintenance mode; some images ship the qsv fork instead, whose flags mostly match but not all.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →