Introduction
csvlens brings spreadsheet-like navigation to CSV files directly in the terminal. Rather than opening a heavyweight application or writing parsing scripts, you can scroll through rows, sort columns, search for values, and filter data interactively from the command line.
What csvlens Does
- Renders CSV data as an aligned, scrollable table in the terminal
- Supports column-based sorting in ascending or descending order
- Provides search to locate specific values across all columns
- Handles large files efficiently with streaming row loading
- Supports TSV and other delimiter-separated formats
Architecture Overview
csvlens reads the CSV file incrementally, parsing rows on demand as the user scrolls. The TUI is built using the ratatui library for Rust terminal applications. Column widths are calculated from visible data, and the table view maintains a scrollable viewport over the full dataset. Search and filter operations scan rows in the background while keeping the UI responsive.
Self-Hosting & Configuration
- Install via Cargo with
cargo install csvlens - Also available through Homebrew and Nix package managers
- Pass the file path as an argument or pipe CSV data through stdin
- Use
-dflag to specify a custom delimiter (e.g.,-d '\t'for TSV) - No configuration file is needed; all options are command-line flags
Key Features
- Vim-style navigation with j/k for rows and h/l for columns
- Column sorting by pressing s on any column header
- Regex-powered search with / to find matching values
- Filter mode to show only rows matching a search query
- Automatic column width detection and horizontal scrolling
Comparison with Similar Tools
- xsv — Fast CSV toolkit for slicing and statistics, not interactive
- Miller — Powerful CSV/JSON processor with its own query language
- VisiData — Feature-rich TUI for exploring tabular data, heavier and Python-based
- column — Basic Unix tool for aligning text, no interactivity
FAQ
Q: Can csvlens handle files with millions of rows? A: csvlens streams data incrementally, so it can open large files without loading everything into memory at once.
Q: Does it support Excel or Google Sheets formats? A: No. csvlens reads plain CSV and other delimiter-separated text files. Convert spreadsheets to CSV first.
Q: How do I change the delimiter?
A: Use the -d flag followed by the delimiter character, for example -d ';' for semicolon-separated files.
Q: Can I export filtered results? A: csvlens is currently a viewer only. For filtering and exporting, pair it with tools like xsv, Miller, or awk.