qsv
A blazing fast CSV data-wrangling toolkit with 50+ subcommands including SQL queries, Lua scripting, statistics, geocoding, and more.
qsv is an actively maintained, feature-rich fork of xsv with
a vastly expanded command set. Where xsv gives you the essentials, qsv adds
SQL queries via Polars, Lua scripting, full-text search, geocoding, data
validation against JSON Schema, Excel/ODS import, and much more — all in a
single fast binary.
Features
- SQL queries — run full SQL against one or more CSV files using the
sqlpcommand, powered by the Polars query engine - 50+ subcommands — a comprehensive toolkit covering nearly every CSV manipulation task imaginable
- Lua scripting — apply arbitrary Lua transformations to rows with the
luaucommand - Statistics — detailed column statistics including quartiles, skewness, cardinality, and null counts
- Schema inference — infer a JSON Schema from your data with
schema, then validate another file against it withvalidate - Excel / ODS support — read
.xlsxand.odsfiles directly withexcel - Geocoding — enrich rows with coordinates or place names via the
geocodecommand - Full-text search — index and search CSV data with the
ftscommand - Snappy compression — transparently reads and writes Snappy-compressed CSV files
- Multithreaded — many subcommands run in parallel across all available cores
Installation
cargo install qsv --locked --features all_full
Pre-built binaries are available on the releases page, including builds with all features pre-enabled.
# Debian / Fedora
# Pre-built Linux binaries are available on the
# [releases page](https://github.com/jqnatividad/qsv/releases).# macOS (Homebrew)
brew install qsvUsage
Everyday operations
# Pretty-print a CSV as an aligned table
qsv table data.csv
# Show summary statistics for each column
qsv stats data.csv | qsv table
# Select specific columns
qsv select name,age,city data.csv
# Search rows matching a pattern in a specific column
qsv search -s country "Germany" data.csv
# Sort by a column
qsv sort -s age data.csv
# Remove duplicate rows
qsv dedup data.csv
# Count rows
qsv count data.csv
# Show the first 5 rows
qsv slice -l 5 data.csvSQL queries with sqlp
# Run a SQL query against a CSV file
qsv sqlp data.csv "SELECT name, age FROM data WHERE age > 30 ORDER BY age DESC"
# Join two CSV files with SQL
qsv sqlp users.csv orders.csv \
"SELECT u.name, o.total FROM users u JOIN orders o ON u.id = o.user_id"
# Aggregation
qsv sqlp sales.csv \
"SELECT region, SUM(revenue) as total FROM sales GROUP BY region ORDER BY total DESC"Schema inference and validation
# Infer a JSON Schema from a CSV file
qsv schema data.csv
# Validate another CSV against the inferred schema
qsv validate data2.csv data.schema.jsonLua scripting with luau
# Add a computed column (full_name = first + last)
qsv luau map full_name 'col.first .. " " .. col.last' data.csv
# Filter rows using a Lua predicate
qsv luau filter 'tonumber(col.age) >= 18' data.csvExcel import
# Convert an Excel sheet to CSV
qsv excel spreadsheet.xlsx
# Import a specific sheet
qsv excel --sheet "Sales Q1" report.xlsxFrequency and cardinality
# Count distinct values in a column
qsv frequency -s country data.csv
# Show the top 10 most common values
qsv frequency -s country --limit 10 data.csvComparison with xsv
qsv is a strict superset of xsv — every xsv command exists in qsv with
the same interface. If you already use xsv, you can alias qsv to xsv and
everything will continue to work while gaining access to the full qsv command
set.
The headline additions over xsv are the sqlp (SQL via Polars), luau (Lua
scripting), schema/validate, excel, geocode, and fts commands, plus
ongoing bug fixes and active maintenance.