My CSV file
200
Service
The code that I put in the interpreter
snav = csv.DictReader(open("screennavigation.csv"), delimiter=',')
print snav.fieldnames
['200']
for line in snav:
... print(line)
...
{'200': 'Service'}
snav["200"]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: DictReader instance has no attribute '__getitem__'
I thought I DictReadershould have returned the dictionary. I suspect I am missing something atrocious.
source
share