Hello,
For some reason, the list that is filled from the CSV file is OK, but when printing the contents of the multidict, I get more than three values:
Thank you.
For some reason, the list that is filled from the CSV file is OK, but when printing the contents of the multidict, I get more than three values:
from collections import defaultdict
mydict = defaultdict(list)
with open('input.csv", mode='r') as infile:
reader = list(csv.reader(infile))
#OK!
for row in reader:
#print(row[2],row[5],row[6],row[10])
#Use ZIP as key, and add multiple values to each key
mydict[row[2]].append(row[5])
mydict[row[2]].append(row[6])
mydict[row[2]].append(row[10])
#NOK! More than three values!
for k in mydict:
print(k,mydict[k])Can you spot what I'm doing wrong?Thank you.
