This repository offers a suite of Python-based automation tools designed to streamline various IT tasks, enhancing efficiency and productivity.
- JSON to CSV: Combines one or more JSON files into a single CSV using the
Polars
library.
The json_to_csv.py
script provides functionality to:
- Load JSON data from multiple files.
- Validate that the files contain a list of dictionaries.
- Combine the data into a single dataset shrinking the dtypes for efficiency.
- Save the dataset as a CSV file with a user-specified name in the directory of choice.
- Run the script from the command line:
python json_to_csv.py <file1.json> <file2.json> ... <fileN.json>
- Follow the on-screen prompts to name the output CSV file.
Suppose you have two JSON files, data1.json
and data2.json
. You can convert them into a single CSV file as follows:
python json_to_csv.py data1.json data2.json
When prompted, enter the desired filename (e.g., combined_data.csv
).
- If a specified file doesn't exist, the script raises a
FileNotFoundError
. - Only JSON files containing a list of dictionaries are accepted. Otherwise, a
ValueError
is raised.
Ensure Python 3.x is installed. Required Python packages include:
Polars
Install dependencies using pip:
pip install polars
Contributions are welcome. Please fork the repository, create a new branch for your feature or bug fix, and submit a pull request.