qsv is a high-performance command-line program for querying, slicing, sorting, analyzing, filtering, enriching, transforming, validating, joining, formatting, and documenting tabular data (CSV, Excel, etc.). It is a fork of the popular xsv utility, significantly expanded with numerous features and commands.
- Language: Rust (requires latest stable or nightly)
- CLI Parser:
docopt(via a maintained forkqsv_docopt) - Core Engine:
csvcrate for fast parsing,polarsfor vectorized queries in certain commands. - Embedded Scripting:
Luau(a fast Lua dialect) andPython(optional). - Template Engine:
MiniJinja.
- Modular Commands: Each command is implemented as a self-contained module in
src/cmd/. - Streaming by Default: Most commands process data in a streaming fashion with constant memory usage, enabling processing of arbitrarily large files.
- Feature Gated: Functionality is modularized using Rust feature flags (e.g.,
polars,luau,python,geocode). - Performance Focused: Employs multithreading (via
rayon), custom memory allocators (mimalloc), and extensive caching strategies.
qsv supports several binary variants tailored for different needs:
qsv: Feature-capable variant (all features enabled).qsvlite: Slimmed-down version (similar to originalxsv).qsvmcp: Optimized for MCP server use (geocode, luau, mcp, polars, self_update).qsvdp: Optimized forDataPusher+.qsvpy: Variant with Python support enabled.
- Build (Release):
cargo build --release --locked --bin qsv --features all_features - Test:
cargo test --features all_features - Lint:
cargo +nightly clippy -F all_features -- -W clippy::perf - Format:
cargo +nightly fmt
- Rust Version: Requires latest stable Rust supported by Homebrew. Nightly is required for formatting and clippy.
- Coding Style:
- Strict adherence to
rustfmt(nightly). - Use
clippyfor performance and correctness checks. unwrap()andexpect()are allowed but should have a safety comment.
- Strict adherence to
- CLI Design: Uses
docoptfor usage-driven argument parsing. Usage text is embedded at the top of each command's source file. - Error Handling: Standardized via
CliErrorandCliResultinsrc/clitypes.rs. Uses macros likefail!,fail_clierror!, etc. - Testing: Extensive test suite (~2,448 tests) in the
tests/directory. Each command should have its owntest_<command>.rsfile. - Logging: Uses
flexi_logger. Level can be controlled viaQSV_LOG_LEVEL.
qsv is highly configurable via environment variables (prefix QSV_) and .env files.
Key variables include:
QSV_DEFAULT_DELIMITER: Set default delimiter.QSV_MAX_JOBS: Control multithreading.QSV_AUTOINDEX_SIZE: Automatically create indices for large files.QSV_MEMORY_CHECK: Enable Out-of-Memory prevention.
For a full list of environment variables, refer to docs/ENVIRONMENT_VARIABLES.md.