0
csv.DictReader
Hi! So at the moment IĀ“m writing a code to explore a csv data file and I have to use the csv.DictReader. But always when I try to return my data IĀ“ll get a TypeError: 'DictReader' object is not subscrptable. Would be great if someone could help me with this. (: The code: import csv with open (r'file_path') as csv_file data= csv.DictReader(csv_file, delimiter = ',') for row in data: print(data['country']) return(data)
4 Answers
+ 5
Bumblebee , please also show us at least the first 3 lines from the csv file. Just copy it from the file and past it here.
It would also be very helpful, if you could show us an output sample.
Thanks!
+ 2
Please provide us with the code with which u are working.
0
import csv
with open (r'file_path') as csv_file
data= csv.DictReader(csv_file, delimiter = ',')
for row in data:
print(data['country'])
return(data)