mirror of
https://github.com/metafy-social/python-scripts.git
synced 2025-02-26 01:48:41 +00:00
16 lines
319 B
Python
16 lines
319 B
Python
|
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(name, "w") as file:
|
||
|
json.dump(data,file)
|
||
|
|
||
|
print(f"file saved at {name}")
|
||
|
|
||
|
|
||
|
|
||
|
csv_to_json()
|