This project provides a simple script to export all sheets of an Excel (.xlsx) file into separate CSV or JSON files.
Download or clone this repository to your local machine:
git clone https://github.com/Johannes-T-E/excel_to_json_csv.gitThen enter the cloned directory:
cd excel_to_json_csvpython -m venv .venv- On Windows:
.venv\Scripts\activate
- On macOS/Linux:
source .venv/bin/activate
You can install all required dependencies in one step using the provided requirements file:
pip install -r requirements.txtPlace your .xlsx file in the project directory, or note its path for use in the next step.
Run the script from the command line, specifying your input file, output directory, and desired format:
python main.py input_file.xlsx -o output_directory -f [csv|json]input_file.xlsx: Path to the Excel file you want to export-o output_directory(optional): Directory to save the exported files (default: current directory)-f [csv|json](optional): Output format for the exported sheets (default: csv)
Export all sheets to CSV files in a dedicated results folder:
python main.py test_file.xlsx -o test_file_results/csv -f csvExport all sheets to JSON files in a dedicated results folder:
python main.py test_file.xlsx -o test_file_results/json -f json- Each sheet will be saved as a separate file named after the sheet (spaces replaced with underscores).
- Files will have the extension
.csvor.jsondepending on the chosen format.
- Exports every sheet in an Excel file as a separate CSV or JSON file
- Automatically creates the output directory if it does not exist
- Handles sheet names with spaces by converting them to underscores in filenames
MIT