JSON to CSV/Excel converter with support for nested data flattening. An interactive command-line tool that converts JSON files to multiple formats.
- Excel (XLSX) - Converts JSON directly to Excel format, preserving nested structures
- Excel (Flattened) - Flattened Excel with transposed structure (data arranged vertically)
- CSV (Basic) - Simple CSV conversion (nested objects may not flatten properly)
- CSV (Flattened) - Transposes nested JSON structures, ideal for BigQuery uploads
- Parquet - Efficient columnar storage format, ideal for analytics and data processing
- Parquet (Flattened) - Flattened Parquet with transposed structure, combining efficiency with restructured data
- Clone the repository:
git clone https://github.com/merkksgit/json-to-csv.git
cd json-to-csv- Install dependencies:
pip install -r requirements.txtpython3 convert.py <input_file.json>The script will prompt you to select a conversion format (1-6).
python3 convert.py scores_data.jsonThen select your desired format:
Select conversion format:
1. Excel (XLSX) - Converts JSON directly to Excel format
2. Excel (Flattened) - Flattened Excel with transposed structure
3. CSV (Basic) - Simple CSV conversion (may not handle nested objects properly)
4. CSV (Flattened) - Flattened CSV with transposed structure (ideal for BigQuery)
5. Parquet - Efficient columnar format (ideal for analytics)
6. Parquet (Flattened) - Flattened Parquet with transposed structure
Enter your choice (1-6): 4
To run the script from anywhere as a command:
- Copy the script to your local scripts directory:
cp convert.py ~/.local/scripts/convert
chmod +x ~/.local/scripts/convert- Make sure ~/.local/scriptsis in your PATH:
export PATH="$HOME/.local/scripts:$PATH"Add this to your ~/.bashrc or ~/.zshrc to make it permanent.
- Run from anywhere:
convert filetoconvert.json- Python 3.6+
- pandas
- openpyxl (for Excel conversion)
The converted file will be saved in the same directory as the input file with the appropriate extension:
- Excel: filename.xlsx
- CSV: filename.csv
- Parquet: filename.parquet