A minimal CLI tool to convert Excel files into CSV format written in Python v3.
Designed for reliability in operational environments where redundant, portable backups (CSV) are required alongside primary spreadsheet workflows.
In many office and accounting workflows, data is often stored in Excel and synced via cloud providers (e.g. OneDrive). While convenient, this setup introduces a single point of failure.
This tool provides a simple fallback mechanism:
- Convert Excel files into plain CSV
- Export all sheets or specific ones
- Batch process entire directories
- Generate consistent, scriptable outputs
The focus is not feature richness, but predictable, safe conversion.
Important
In case you don't know, converting Excel files to CSV format will lose the formatting, formulas, etc.
It will only stores the calculated values of the cells.
By converting to CSV, you can have an emergency backup of your Excel data that can be saved locally (e.g., USB drive).
- Lightweight – Designed with minimal dependencies for easy setup and maintenance
- Excel to CSV Conversion – Convert a single Excel file into CSV format
- Batch Processing – Convert entire folders of Excel files in one command
| File Type | Extension | Supported |
|---|---|---|
| Excel 97-2003 Workbook | .xls |
❌ |
| Excel Workbook | .xlsx |
✅ |
| Excel Macro-Enabled Workbook | .xlsm |
✅ |
| Excel Binary Workbook | .xlsb |
✅ |
| Excel Open XML Spreadsheet | .ods |
❌ |
- Active sheet (default behavior)
- Specific sheet using
--sheet - All sheets using
--all-sheets
- Save to a file in single-file mode
- Save to a directory in batch mode
- Optional template-based naming for generated files (
--template)
- Cross-platform support – Works seamlessly on Windows, Linux, and macOS
- Memory efficient – Uses read-only processing to keep memory usage low
This project originated from a practical issue encountered while managing financial data backups in a local workflow.
Important
Please take as important note, DO NOT upload any sensitive files such as company financial data either to public or private repository which may be violating the company policy and I'm not responsible for that.
An initial approach involved using Git for versioning Excel files. However, since Excel formats (e.g., .xlsx) are binary, even small changes resulted in large diffs and rapid growth of the .git directory when committed directly without Git LFS. This made the repository inefficient and difficult to maintain over time.
To address this, a simple conversion step was introduced: transform Excel files into CSV before committing. Unlike binary formats, CSV files are text-based, enabling meaningful diffs, smaller repository size, and better traceability of changes.
What began as a small utility script evolved into a dedicated CLI tool focused on one purpose—providing a reliable way to generate lightweight, version-friendly backups from spreadsheet data.
pipx is a tool for installing and running Python applications in isolated environments. Best for Ubuntu 23.04+, Debian 12+, and Fedora 38+ (these are distros that adopts PEP 668).
sudo apt install pipxFor Windows users:
python -m pip install pipx && python -m pipx ensurepathOr, check
pipxinstallation guide for more information on how to installpipx.
pipx install git+https://github.com/mitsuki31/xls2csv.git@latestxls2csv --versionWarning
Recommended to use pipx instead, pip can sometimes cause dependency conflicts in some environments.
pip install git+https://github.com/mitsuki31/xls2csv.git@latestYou may need
--userdepending on your environment.
After installation:
xls2csv --versiongit clone https://github.com/mitsuki31/xls2csv.gitcd xls2csvUnix
./setup.shWindows (PowerShell)
.\setup.ps1Unix-like (alternative)
python -m venv .venv && \
. ./.venv/bin/activate && \
pip install -r requirements.txtpython -m xls2csv.cli --versionxls2csv [OPTIONS] INPUT_PATHINPUT_PATH determines behavior:
- File → single conversion
- Directory → batch conversion
See options for more detailed information.
Note
- Sheet names are sanitized for filesystem compatibility
- For example:
April/2026→April_2026
- For example:
- Empty or invalid Excel files will raise errors
- CSV encoding is set to UTF-8
- Read-only Excel loading for lower memory usage
xls2csv report.xlsxNote
If you don't specify the output file, it will be saved in the same folder as the input file.
xls2csv report.xlsx -o output.csvNote
The -o / --output option accepts either a file path or a directory:
- If a file extension is provided (e.g.
a/b/c.csv), the output is written to that file. - If no extension is provided, the value is treated as a directory.
xls2csv report.xlsx --all-sheetsxls2csv report.xlsx -s 2026-01xls2csv ./reportsxls2csv ./reports -o ./outxls2csv report.xlsx -o 'output-%name%-%sheet%.csv'| Option | Description |
|---|---|
-o, --output |
Output file (single mode) or directory |
-t, --template |
Template for output file name (default: %(name)-%(sheet).%(ext)) |
-s, --sheet |
Convert specific sheet |
--all-sheets |
Export all sheets |
-f, --force, --overwrite |
Overwrite existing files |
-v, --version |
Show version information |
--help |
Show help message |
| Input | Output |
|---|---|
No -o |
Same folder as source |
-o file.csv |
Exact file |
-o folder/ |
File inside folder |
| Input | Output |
|---|---|
No -o |
Same folder |
-o folder/ |
All files saved there |
-o file.csv |
❌ Invalid |
You can specify a placeholder in the output file name using --template option.
| Placeholder | Description |
|---|---|
%(name) |
The filename of the input file |
%(sheet) |
The sheet name of the input file |
%(ext) |
The extension of the output file (always csv) |
%(date) |
The current date in YYYY-MM-DD format |
%(year) |
The current year in YYYY format |
%(month) |
The current month in MM format |
%(day) |
The current day in DD format |
%(day_s) |
The current day of the week in DDD format (e.g., Mon) |
Example:
xls2csv report.xlsx -t 'output-%(name)-%(sheet).%(ext)'Tip
The %(date) placeholder is a shortcut for %(year)-%(month)-%(day).
Note
Default template string for the output file is %(name)-[%(sheet)].%(ext).
Example output file:
report-[Sheet1].csv
Setup environment:
- Unix
./setup.sh && . .venv/bin/activate
- Windows (PowerShell)
.\setup.ps1
Install locally:
pipx install -e .Run:
xls2csv --version© 2026 Ryuu Mitsuki. Licensed under the MIT License.