Welcome to CSV-to-JSON-Converter-Using-Python, this Python script converts CSV (Comma-Separated Values) files to JSON (JavaScript Object Notation) files. It's designed for basic conversion and assumes well-formatted CSV files.
Project Overview
CSV-to-JSON-Converter-Using-Python enables you to convert CSV files, commonly used for tabular data, into JSON format. This conversion allows for better data management, analysis, and sharing.
Features
-
Exception Handling: CSV-to-JSON-Converter-Using-Python incorporates robust exception handling to ensure smooth data conversion.
-
Converts CSV data into a JSON object structure.
-
Handles basic CSV formatting, including headers as the first row.
-
Outputs the converted JSON data to a new file.
How to Use
-
Create a virtal enviornment and activate it.
python -m venv pr-venv
-
Install all the prereqesites from requirements.txt.
pip install -r .\requirements.txt
-
Edit .env file as per your requirement / Declare these enviornment variables as follows: (Windows)
$Env:SRC_BASE_DIR = 'data/retail_db' $Env:TGT_BASE_DIR = 'data/retail_db_json'
-
Run app.py as per requirements.
Use Case
This would convert all the csv files present in data/retail_db to json.
python app.py
To convert files specefic to dataset.
python app.py '[\"orders\" ,\"depatment\", \"order_items\"]'
--This would convert files of only orders and order_items dataset to JSON files as there is a typo in departments hence proving exception handling.