Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/universal_devkit/scripts/csv_to_json.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import csv
import json
import uuid


def main(csv_in, json_out):
Expand All @@ -10,12 +11,12 @@ def main(csv_in, json_out):
csv_in (str): the path to the CSV input file
json_out (str): the path to save the resulting JSON file
"""
data_list = list(csv.DictReader(open(csv_in)))
data_list = list(csv.DictReader(open(csv_in), skipinitialspace=True))

# for obj in data_list:
# if token not in obj:
# # Avoid overwriting existing tokens
# obj["token"] = uuid.uuid4().hex
for obj in data_list:
if "token" not in obj:
# Avoid overwriting existing tokens
obj["token"] = uuid.uuid4().hex

with open(json_out, "w") as f:
json.dump(data_list, f)
Expand Down