Essential CLI Tools for Data Analysts
While graphical tools like Excel, Power BI, and Jupyter Notebooks are standard in data analysis, the command-line interface (CLI) remains one of the most powerful and fastest environments for exploring, filtering, and cleaning data.
Here are the top CLI tools every data analyst should integrate into their daily workflow.
1. csvkit: The Swiss Army Knife for CSVs
csvkit is a suite of command-line tools for converting to and working with CSV files. It brings database-like queries and inspection tools directly to your terminal.
# Preview column names and data types of a CSVcsvcut -n sales_data.csv
# Filter rows where region is 'West' and output specific columnscsvgrep -c "Region" -m "West" sales_data.csv | csvcut -c "Date","Customer","Amount"With csvsql, you can even run SQL queries directly on your CSV files without importing them to a database first:
csvsql --query "SELECT Category, SUM(Amount) FROM sales_data GROUP BY Category" sales_data.csv2. jq: Lightweight and Flexible JSON Processor
If you work with web APIs or NoSQL data sources, you’ll constantly encounter JSON. jq is the ultimate tool to slice, filter, map, and transform JSON datasets.
# Extract value of a specific keycurl -s https://api.github.com/repos/jayabelajar/muyoy | jq '.stargazers_count'
# Map and filter array elementscat users.json | jq '[.[] | select(.active == true) | {name: .name, email: .email}]'3. xsv: High-Performance CSV Handler Written in Rust
When dealing with large CSV files (millions of rows) where Python’s Pandas or Excel might struggle or slow down, xsv is incredibly fast. Written in Rust, it can index, slice, and partition large files in milliseconds.
| Operation | Pandas (Python) | xsv (Rust) |
|---|---|---|
| Index Creation | Needs full load in memory | Under 0.1s |
| Row Count | ~1.5s for 10M rows | ~0.08s |
| Slicing Columns | ~2.2s | ~0.15s |
# Quickly view descriptive statistics of a CSV filexsv stats sales_large.csv
# Slice lines 10,000 to 10,500xsv slice -i 10000-10500 sales_large.csv > sample.csv4. ripgrep (rg): Fast Text Pattern Searcher
ripgrep is a line-oriented search tool that recursively searches your current directory for a regex pattern. It is invaluable for locating specific IDs, variables, or functions across raw log files and data exports.
# Search for a transaction ID across all log files in a directoryrg "TXN-90218" logs/By mastering these simple terminal tools, you can automate minor cleaning and parsing tasks, saving significant time before feeding clean data into your scripting environments or BI tools.