Newer
Older
import csv
import json
csv_path = r'C:\Users\12408\Downloads\test.csv' #Change according to the location of csv file
json_path = r'./src/utils/csvtopy.json'
with open(csv_path, 'r', encoding='ISO-8859-1') as csvfile, open(json_path, 'w') as jsonfile:
reader = csv.reader(csvfile)
headers = next(reader)
rows = []
for row in reader:
row_dict = {}
for i in range(len(headers)):
row_dict[headers[i]] = row[i]
rows.append(row_dict)