Mar-18-2021, 11:07 AM
(Mar-18-2021, 10:11 AM)Larz60+ Wrote: you can place the header in a list,
then use csv reader (not DictReader)
an example of using zip would be:
header = ['col1', 'col2', 'col3', ...] # replace with actual column names with open("boardgames.csv", 'r') as csvfile: reader = csv.reader(csvfile) for xrow in reader: row = dict(zip(header, xrow)) ...the output looks like a json file would be a better choice than your method.
In my opinion a json file would be our best option here, however my exercise needs a csvs file. I actually fixed the problem thank you for your help. I just added a function that initializes the csv and writes the headers, when the program begins. Thanks!