
# https://www.globalsino.com/ICs/
# Convert a CSV file to a JSON file

import csv
import json

csv_path = r"C:\GlobalSino2\ICs\theFileList.csv"
json_path = r"C:\GlobalSino2\ICs\theFileList.json"
 
def csv_to_json(csv_path, json_path):
    data_dict = {}
 
    with open(csv_path, encoding = 'utf-8') as csv_file_handler:
        csv_reader = csv.DictReader(csv_file_handler)
 
        for rows in csv_reader:
            key = rows["TheFiles"]
            data_dict[key] = rows

    with open(json_path, 'w', encoding = 'utf-8') as json_file_handler:
        json_file_handler.write(json.dumps(data_dict, indent = 4))

csv_to_json(csv_path, json_path)
