winget install --id=YS-L.csvlens -e
csvlens is a command line CSV file viewer. It is like less but made for CSV.
csvlens is a command-line CSV file viewer designed to provide an efficient and intuitive way to navigate and analyze CSV data. It offers a terminal-based interface optimized for CSV files, allowing users to scroll through rows and columns, search for content, filter data, and customize the display.
Key Features:
Audience & Benefit: Ideal for developers, data analysts, and system administrators who work with CSV files. csvlens enables users to quickly view, navigate, filter, and analyze large CSV datasets directly from the command line without needing a graphical interface.
Installation: csvlens can be installed via winget, making it easily accessible on supported platforms.
csvlens
is a command line CSV file viewer. It is like less
but made
for CSV.
Run csvlens
by providing the CSV filename:
csvlens
Pipe CSV data directly to csvlens
:
| csvlens
Key | Action |
---|---|
hjkl (or ← ↓ ↑→ ) | Scroll one row or column in the given direction |
Ctrl + f (or Page Down ) | Scroll one window down |
Ctrl + b (or Page Up ) | Scroll one window up |
Ctrl + d (or d ) | Scroll half a window down |
Ctrl + u (or u ) | Scroll half a window up |
Ctrl + h | Scroll one window left |
Ctrl + l | Scroll one window right |
Ctrl + ← | Scroll left to first column |
Ctrl + → | Scroll right to last column |
G (or End ) | Go to bottom |
g (or Home ) | Go to top |
G | Go to line n |
/ | Find content matching regex and highlight matches |
n (in Find mode) | Jump to next result |
N (in Find mode) | Jump to previous result |
& | Filter rows using regex (show only matches) |
* | Filter columns using regex (show only matches) |
TAB | Toggle between row, column or cell selection modes |
> | Increase selected column's width |
< | Decrease selected column's width |
Shift + ↓ (or Shift + j ) | Sort rows or toggle sort direction by the selected column |
# (in Cell mode) | Find and highlight rows like the selected cell |
@ (in Cell mode) | Filter rows like the selected cell |
y | Copy the selected row or cell to clipboard |
Enter (in Cell mode) | Print the selected cell to stdout and exit |
-S | Toggle line wrapping |
-W | Toggle line wrapping by words |
f | Freeze this number of columns from the left |
r | Reset to default view (clear all filters and custom column widths) |
H (or ? ) | Display help |
q | Exit |
-d
: Use this delimiter when parsing the CSV
(e.g. csvlens file.csv -d '\t'
).
Specify -d auto
to auto-detect the delimiter.
-t
, --tab-separated
: Use tab as the delimiter (when specified, -d
is ignored).
-i
, --ignore-case
: Ignore case when searching. This flag is ignored if any
uppercase letters are present in the search string.
--no-headers
: Do not interpret the first row as headers.
--columns
: Use this regex to select columns to display by default.
Example: "column1|column2"
matches "column1"
, "column2"
, and also column names like
"column11"
, "column22"
.
--filter
: Use this regex to filter rows to display by default.
The regex is matched against each cell in every column.
Example: "value1|value2"
filters rows with any cells containing "value1"
, "value2"
, or text
like "my_value1"
or "value234"
.
--find
: Use this regex to find and highlight matches by default.
The regex is matched against each cell in every column.
Example: "value1|value2"
highlights text in any cells containing "value1"
, "value2"
, or
longer text like "value1_ok"
.
--echo-column
: Print the value of this column at the selected
row to stdout on Enter
key and then exit.
--prompt
: Show a custom prompt message in the status bar. Supports ANSI escape codes
for colored or styled text.
Example:
csvlens Pokemon.csv --prompt $'\e[1m\e[32mSelect a Pokémon!\e[0m'
--color-columns
(or --colorful
): Display each column in a different color.
You can download the tar.xz
or zip
file matching your operating system from the
releases page, extract it and execute the csvlens
binary.
For macOS, csvlens
is available on Homebrew. You can
install it using:
brew install csvlens
csvlens
is available in the official repositories. You can install it using:
pacman -S csvlens
For Windows, csvlens
is available on winget. You can install it using:
winget install --id YS-L.csvlens
csvlens
is available as a FreeBSD pkg. You can install it using:
pkg install csvlens
csvlens
is available on pkgsrc. If you're using NetBSD you can install it using:
pkgin install csvlens
csvlens
is available as an OpenBSD port. If you're using OpenBSD 7.6-current or later, you can install it using:
doas pkg_add csvlens
cargo install csvlens
Or, build and install from source after cloning this repo:
cargo install --path $(pwd)
This crate allows you to use csvlens as a library.
In your Cargo.toml
, add the following:
[dependencies]
csvlens = { version = "0.12.0", default-features = false, features = ["clipboard"] }
Here's a simple example of how to use csvlens
as a library (Documentation):
use csvlens::run_csvlens;
let out = run_csvlens(&["/path/to/your.csv"]).unwrap();
if let Some(selected_cell) = out {
println!("Selected: {}", selected_cell);
}
For more advanced usage, you can use CsvlensOptions
to customize the behavior:
use csvlens::{run_csvlens_with_options, CsvlensOptions};
let options = CsvlensOptions {
filename: "/path/to/your.csv".to_string(),
delimiter: Some("|".to_string()),
ignore_case: true,
debug: true,
..Default::default()
};
let out = run_csvlens_with_options(options).unwrap();
if let Some(selected_cell) = out {
println!("Selected: {}", selected_cell);
}