Merge pull request #51 from sarvesh4396/master

Add CSV to JSON converter
This commit is contained in:
Advaita Saha 2022-10-02 15:08:08 +05:30 committed by GitHub
commit 1b4bcd2258
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,8 @@
# CSV to EXCEL
This simple script will convert CSV file to json.
## Usage
* requires pandas
* Use `pip install pandas`
* Run `python script.py`

View File

@ -0,0 +1,15 @@
import pandas as pd
import os,json
def csv_to_json():
file = input("Enter csv path: ")
df = pd.read_csv(file)
name=os.path.basename(file).replace("csv","json")
data =df.to_dict("r")
with open(file,'w') as f:
json.dump(df, d)
print(f"file saved at {name}")
csv_to_json()