in2csv
Convert various file formats to CSV
TLDR
Convert an XLS file to CSV
Convert a DBF file to a CSV file
Convert a specific sheet from an XLSX file to CSV
Pipe a JSON file to in2csv
SYNOPSIS
in2csv [OPTIONS] [FILE]
PARAMETERS
-h, --help
Show help message and exit
-v, --version
Show version information
-f SHEET, --sheet SHEET
Excel sheet name or number (0-indexed)
-F, --formula
Keep formulas as strings instead of values
--no-inference
Disable type inference; output as all strings
--names-only
Output only header row(s)
--date-format DATE_FORMAT
Format for Excel dates (e.g., '%Y-%m-%d')
--datetime-format DATETIME_FORMAT
Format for Excel datetimes
--sheet-regex
Treat sheet specifier as regex
-n NAMECASE, --namecase NAMECASE
Case for header names: lower, upper, preserve (default), or cap
-d DELIM, --delimiter DELIM
CSV delimiter (default: ',')
-t, --tabs
Use tabs as delimiter
-q QUOTECHAR, --quotechar QUOTECHAR
CSV quote character (default: '"')
-u, --unicode
Output UTF-8 CSV
-z, --zero
Treat blank lines as empty rows
-e, --escapechar ESCAPECHAR
CSV escape character
-b, --doublequote
Use double-quote escaping
-p, --quoting QUOTING
Quoting: all, minimal, none, nonnumeric (default: minimal)
-l LINES, --lineterminator LINES
Line terminator for output
DESCRIPTION
in2csv is a powerful command-line utility from the csvkit suite designed to convert Microsoft Excel files (.xls and .xlsx) into CSV format.
It intelligently handles spreadsheets by inferring data types, preserving formulas (optionally evaluating them), and supporting multiple sheets. Key features include sheet selection via index or name, disabling type inference for raw output, custom date/datetime formatting, and outputting only headers with --names-only.
Ideal for data pipelines, automation, and ETL processes, it reads from files or stdin, making it versatile for scripting. It uses xlrd for .xls and openpyxl for .xlsx, ensuring broad compatibility.
Unlike simple converters, in2csv maintains data fidelity, handles large files efficiently, and integrates seamlessly with other csvkit tools like csvlook and csvstat for inspection and analysis.
CAVEATS
Requires Python dependencies like xlrd (.xls) and openpyxl (.xlsx); large files may consume significant memory.
Formulas in .xls may not evaluate identically due to engine differences.
Does not support password-protected files.
INPUT SOURCES
Reads from FILE or stdin if omitted. Multiple files not supported directly; use shell loops.
TYPE INFERENCE
Automatically detects integers, floats, booleans, dates. Use --no-inference for verbatim strings.
SHEET HANDLING
Default: first sheet. Use -f for others; --names-only lists headers across sheets.
HISTORY
Developed by Christopher F. Miller as part of csvkit (first release ~2010). Now maintained under the csvkit organization on GitHub. Evolved with Python 3 support and enhanced Excel backends in versions 1.0+.


