I try to populate the default dictionary with csv data and I get a key error
for i in range(0,1):
result = co.defaultdict(list)
with open(os.path.join(inputdir,tablelist[i])) as f:
csv_reader = csv.reader(f)
csv_headings = next(csv_reader)
read = csv.DictReader(f)
for line in read:
for j in range(1,len(csv_headings)):
error here
for csv data
API,CNTYNM,PRMT,
4700100002,Barbour,2,
4700100003,Barbour,3,
4700100004,Barbour,4,
a key error for the API, which means for me that something with the dictreader is not working properly, can anyone give any advice?
source
share