Blog
CSVterminalCLI

Tools to Process CSV Files in the Terminal

August 28, 2026 ·

Exports, logs, and database dumps often land as CSV. In the terminal you can inspect headers, drop columns, filter rows, and pipe results into the next step - without opening a spreadsheet. A handful of CLI tools make that workflow fast and scriptable.

This guide covers the tools worth installing, the commands you will reach for daily, and when a private browser tool is a better fit than a one-liner.

What you need from a CSV CLI

Good terminal CSV tools handle real-world files, not just ideal ones:

  • Quoted fields with commas and newlines inside cells

  • Headers you can select by name, not only by index

  • Streaming so multi-million-row files do not need full RAM

  • Easy piping into sort, jq, or other commands

Plain cut and awk work on simple files. Once quoting gets messy, prefer a CSV-aware tool.

Quick look: which tool when

  • csvkit - Python suite; great headers, SQL-ish queries, and format conversion.

  • xsv - Rust, very fast; cut, search, stats, sample on large files.

  • Miller (mlr) - name-based DSL for reshape, join, and aggregates; CSV, TSV, JSON, and more.

  • Unix basics - head, wc, sort, uniq for tiny, clean files or after a CSV tool has simplified the data.

csvkit

csvkit is a set of command-line utilities for converting and working with CSV. Install with pip:

pip install csvkit

Core commands:

# Peek at structure
csvcut -n data.csv          # list column names + indexes
csvstat data.csv            # type guesses, nulls, min/max
csvclean data.csv           # fix common formatting issues

# Select and filter
csvcut -c id,name,email data.csv
csvgrep -c status -m open tickets.csv
csvgrep -c email -r '@example\\.com$' users.csv

# SQL against a file (SQLite under the hood)
csvsql --query "SELECT city, COUNT(*) FROM data GROUP BY city" data.csv

# Convert
in2csv workbook.xlsx > sheet.csv
csvjson data.csv > data.json
csvformat -T data.csv > data.tsv

csvcut -n is the habit that saves time: always check headers before scripting column indexes. For a one-off Excel export without installing Python, use Excel to CSV in the browser.

xsv

xsv is a fast CSV toolkit written in Rust. Ideal when files are large and you want simple, focused subcommands.

# macOS
brew install xsv

# Inspect
xsv headers data.csv
xsv count data.csv
xsv stats data.csv
xsv sample 20 data.csv
xsv slice -s 0 -l 10 data.csv

# Shape
xsv select id,name,email data.csv
xsv search -s status open tickets.csv
xsv sort -s created_at data.csv
xsv frequency -s city data.csv
xsv join id users.csv user_id orders.csv

Pipe stages together. Select first, then search, so later steps see fewer columns and rows:

xsv select id,status,amount orders.csv \\
  | xsv search -s status paid \\
  | xsv stats

For frequency tables in your browser, load a CSV in DB in Browser and query it with GROUP BY and COUNT(*).

Miller (mlr)

Miller treats each row as a record with named fields. The same verbs work across CSV, TSV, JSON, and other formats - useful when your pipeline mixes types.

brew install miller   # or: apt install miller

mlr --csv head -n 5 data.csv
mlr --csv cut -f id,name,email data.csv
mlr --csv filter '$amount > 100' orders.csv
mlr --csv sort -f city then head -n 20 data.csv
mlr --csv stats1 -a count,sum,mean -f amount -g status orders.csv
mlr --csv put '$total = $qty * $price' line_items.csv
mlr --c2j cat data.csv > data.json
mlr --csv join -j user_id -f users.csv orders.csv

put and filter use field names with $, which reads closer to a spreadsheet formula than index- based awk. For JSON-heavy work after conversion, see jq for JSON Processing from the Terminal .

Classic Unix tools (simple files only)

On clean, unquoted CSV, built-ins are enough for a quick look. They break on commas inside quotes - use them after a proper CSV tool has narrowed the file, or only on known-safe data.

head -n 5 data.csv
wc -l data.csv
cut -d',' -f1,3 data.csv
sort -t',' -k2 data.csv
awk -F',' 'NR==1 || $3 == "open"' tickets.csv

Prefer xsv select or csvcut over cut whenever the file might contain quoted commas.

Recipes worth memorizing

# Column names only
xsv headers data.csv
# or: csvcut -n data.csv

# Keep rows where email domain matches
csvgrep -c email -r '@acme\\.com$' users.csv

# Top cities by count
xsv select city data.csv | xsv frequency -s city | head

# Drop duplicate rows on a key
mlr --csv uniq -f email users.csv
# or browser: /remove-duplicates

# Split a huge file into chunks of N data rows (header repeated)
# xsv has split; csvkit: csvsplit

# Excel → CSV then filter
in2csv report.xlsx | xsv search -s region West > west.csv

Messy files first

Bad delimiters, BOM marks, and inconsistent quoting waste more time than learning a new flag. Validate and clean before heavy pipelines:

  • csvclean / csvstat for a first pass in the shell

  • CSV Preview for a visual inspection of headers and column alignment

For a full cleanup workflow, see How to Clean Messy CSV Files .

When browser tools are enough

CLI tools win for automation, CI, and multi-gigabyte files. For a one-time edit, a visual check, or sharing a result with someone who will not run shell commands, browser-only tools are often simpler:

Getting started

Install one toolkit (xsv for speed, csvkit for SQL and Excel, or Miller for named-field pipelines). Run headers/count/stats on a sample file, then practice select and a single filter. When you need a table for a teammate who will not open a terminal, finish in CSV Preview or convert with CSV to Excel .

Written by

The RividTech Experts Team builds and maintains RividTech's data tools and writes its guides. Every guide is checked against the tools' actual behavior and updated when that behavior changes.

Spotted an error? Email info@rividtech.online.