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 sqlp command, 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 luau command
  • 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 with validate
  • Excel / ODS support — read .xlsx and .ods files directly with excel
  • Geocoding — enrich rows with coordinates or place names via the geocode command
  • Full-text search — index and search CSV data with the fts command
  • 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 qsv

Usage

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.csv

SQL 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.json

Lua 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.csv

Excel import

# Convert an Excel sheet to CSV
qsv excel spreadsheet.xlsx

# Import a specific sheet
qsv excel --sheet "Sales Q1" report.xlsx

Frequency 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.csv

Comparison 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.