CSV Tools
Core Capabilities
| Action | Description | Command |
|---|---|---|
| Info | Get row count, columns, headers, file size | --action info --input file.csv |
| View | Preview rows with pagination | --action view --input file.csv --limit 10 |
| Filter | Filter rows by column value | --action filter --input file.csv --column City --value "Beijing" |
| Merge | Combine multiple CSV files | --action merge --inputs a.csv b.csv --output merged.csv |
| Stats | Column statistics (numeric or text) | --action stats --input file.csv --column Price |
| Convert | CSV → JSON or JSONL | --action convert --input file.csv --to json |
Usage
# Quick info
python3 skills/csv-tools/scripts/csv_tools.py --action info --input data.csv
# View first 10 rows
python3 skills/csv-tools/scripts/csv_tools.py --action view --input data.csv --limit 10
# Filter rows
python3 skills/csv-tools/scripts/csv_tools.py --action filter --input data.csv --column City --value "Beijing" --output filtered.csv
# Merge two CSVs
python3 skills/csv-tools/scripts/csv_tools.py --action merge --inputs a.csv b.csv --output combined.csv
# Column stats
python3 skills/csv-tools/scripts/csv_tools.py --action stats --input sales.csv --column Revenue
# Convert to JSON
python3 skills/csv-tools/scripts/csv_tools.py --action convert --input data.csv --to json --output data.json
# Handle TSV (tab-separated)
python3 skills/csv-tools/scripts/csv_tools.py --action info --input data.tsv --delimiter $'\t'
Gotchas
- Encoding: auto-detects UTF-8 BOM. For other encodings, convert first.
- Large files:
view --limitandfilterwith output are safe for large files (streaming).statsloads all rows. - Merge requires same column headers across all files.
- Stats numeric auto-detects by trying to parse numbers (strips
$,,,¥). - TSV files: use
--delimiter $'\t'