Reading CSV files. I want to raise error message if there is no any header from following list. It must be atleast one header in csv file.
Headers are
age sex city. I’m trying like this. thanks
with open('data.csv') as f:
cf = csv.DictReader(f, fieldnames=['city'])
for row in cf:
print row['city']
How about this?