Skip to content
Snippets Groups Projects
Commit bb05f79e authored by Emily Nicole Adams's avatar Emily Nicole Adams
Browse files

renormalizing files

parent 40834f61
1 merge request!6Git attributes
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)
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)
json.dump(rows, jsonfile, indent=4)
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment