csvkit in2csv: Convert Excel and JSON to CSV
in2csv converts XLSX, XLS, JSON and fixed-width input into CSV so the rest of csvkit (and any CSV tool) can read it.
Pipelines often receive an Excel export or a JSON dump. in2csv normalizes them to CSV in one step, the front door to the whole csvkit toolchain.
What it does
in2csv detects the input format (or takes it from -f) and writes CSV to stdout. It handles .xlsx/.xls (with --sheet to pick a tab), JSON arrays of objects, and fixed-width files given a schema.
Common usage
# Excel -> CSV
in2csv report.xlsx > report.csv
# pick a specific worksheet
in2csv -f xlsx --sheet "Q1" report.xlsx
# JSON array -> CSV
in2csv -f json data.json > data.csvOptions
| Flag | What it does |
|---|---|
| -f, --format <fmt> | Input format: csv, json, xls, xlsx, ndjson, fixed |
| --sheet <name> | Worksheet to extract from an Excel file |
| -k, --key <path> | For JSON: path to the array of records |
| --names | List worksheet names in an Excel file |
| -e, --encoding <enc> | Input encoding |
| -d, --delimiter <c> | Output delimiter override |
In CI
When an upstream job hands you an .xlsx, run in2csv report.xlsx | csvcut -c id,total to go straight from spreadsheet to the columns you need, no manual export. Use --names first if you are unsure which sheet holds the data.
Common errors in CI
Reading from stdin without -f raises You must specify a format when providing data via STDIN; always set -f. Excel support needs the optional dependency; XLRDError or a missing-module error means openpyxl/xlrd is not installed (modern csvkit uses openpyxl for xlsx). A wrong --sheet name fails with a sheet-not-found error; list them with --names.