xsv — Fast CSV Toolkit Written in Rust
xsv is a blazing-fast command-line toolkit for working with CSV data. It provides indexing, slicing, searching, joining, aggregation, and statistics — processing millions of rows per second for data analysis, ETL pipelines, and CSV manipulation.
Agent 可直接安装
这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。
npx -y tokrepo@latest install 82f0e8a4-3745-11f1-9bc6-00163e2b0d79 --target codex先 dry-run 确认安装计划,再运行此命令。
What it is
xsv is a command-line toolkit for working with CSV data, written in Rust. It provides a suite of subcommands for viewing headers, slicing rows, selecting columns, searching with regex, joining files, computing statistics, and reformatting output. Rust compilation gives xsv the ability to process millions of rows per second on commodity hardware.
xsv targets data engineers, analysts, and developers who work with CSV files in the terminal. It fills the gap between simple tools like cut and awk (which do not understand CSV quoting) and full data processing frameworks (which require writing programs).
How it saves time or tokens
xsv operates on CSV data natively, handling quoted fields, escaped commas, and multi-line values correctly. A single xsv command replaces multi-step awk/sed pipelines. The index subcommand creates a binary index for instant random access into large files. Statistics computation runs in streaming mode without loading the entire file into memory.
How to use
- Install xsv via
brew install xsvon macOS orcargo install xsvfrom source. - Explore CSV structure with
xsv headers data.csvandxsv stats data.csv. - Chain subcommands with pipes: select, filter, sort, and aggregate in a single pipeline.
Example
# View CSV headers
xsv headers data.csv
# First 10 rows, pretty-printed
xsv slice -l 10 data.csv | xsv table
# Select specific columns
xsv select name,email,age data.csv
# Search rows by regex
xsv search -s status 'active' data.csv
# Statistics for all columns
xsv stats data.csv | xsv table
# Join two CSV files on a common column
xsv join id users.csv user_id orders.csv
# Count rows by category
xsv frequency -s category data.csv
Related on TokRepo
- Automation Tools — CLI tools for data processing
- Coding AI Tools — Developer productivity tools
Common pitfalls
- xsv is CSV-only. It does not support JSON, TSV with tab delimiters (use
--delimiterflag), or other formats. For multi-format needs, consider Miller. - The xsv project has not received major updates recently. For active development, check out qsv, a maintained fork with additional features.
- Large file joins load the smaller file into memory. Ensure adequate RAM when joining against files with millions of rows.
常见问题
xsv is significantly faster than awk for CSV-specific operations because it uses Rust's zero-cost abstractions and handles CSV parsing natively. For simple field extraction, xsv processes millions of rows per second. awk is faster for unstructured text but does not understand CSV quoting.
Yes. xsv fully supports RFC 4180 CSV, including quoted fields with commas, escaped quotes, and multi-line values. This is a key advantage over awk and cut, which treat commas as simple delimiters.
qsv is an actively maintained fork of xsv with additional features including JSON output, Python scripting support, and more subcommands. If you need features beyond what xsv offers, qsv is the recommended alternative.
xsv processes most operations in streaming mode without loading the entire file. Statistics, searching, and slicing work on arbitrarily large files. Join operations load the smaller file into memory, which may be a limitation.
Yes. xsv reads from stdin and writes to stdout, making it fully compatible with Unix pipes. You can chain xsv commands or mix them with grep, sort, head, and other standard tools.
引用来源 (3)
- xsv GitHub— xsv provides indexing, slicing, searching, joining, and statistics for CSV data
- xsv README— Rust-based CSV processing with RFC 4180 compliance
- Rust csv crate— CSV data processing patterns and command-line tooling
讨论
相关资产
Yazi — Blazing Fast Terminal File Manager in Rust
Yazi is a blazing fast terminal file manager written in Rust, based on async I/O. Preview images and videos in terminal, fuzzy search, batch operations, plugin system, and seamless integration with tools like fzf, zoxide, and rg.
GitUI — Blazing-Fast Terminal UI for Git Written in Rust
GitUI brings a Rust-fast terminal interface to Git: browse commits, stage hunks, view diffs, manage branches, and resolve conflicts — all without leaving the keyboard. A great complement (or alternative) to lazygit.
Polars — Blazingly Fast DataFrame Library in Rust
Polars is an extremely fast DataFrame library written in Rust with bindings for Python, Node.js, and R. Uses Apache Arrow columnar format, lazy evaluation, and multi-threaded query execution. The modern alternative to pandas for data engineering and analytics.
Zola — Fast Static Site Generator in a Single Rust Binary
Zola is a fast static site generator built as a single Rust binary with everything built in: Sass compilation, syntax highlighting, table of contents, search index, image processing, and shortcodes. No external dependencies or plugins needed.