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)

5th Dec 2020, 3:20 PM
Bumblebee
4 Respuestas
+ 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!
5th Dec 2020, 5:54 PM
Lothar
Lothar - avatar
+ 2
Please provide us with the code with which u are working.
5th Dec 2020, 3:26 PM
Charitra
Charitra - avatar
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)
5th Dec 2020, 4:48 PM
Bumblebee