+ 1
I am trying to read a csv file into a python dictionary (nested)but it's giving me an error saying list index out of range
import csv f=open('names.csv','r') reader=csv.reader(f) mydict={row[0]:{'age':row[1],'color':[2]}for row in reader }
1 ответ
+ 1
Give an example of the data you want to read, first 3 lines should suffice.
You should access files using "with" like so:
with(open('names.csv','r')) as f: