Trying to read headers for a csv file with:
reader = csv.DictReader(open(PATH_FILE),skipinitialspace=True)
headers = reader.fieldnames
for header in sorted(set(headers)):
It worked on development server, throws this error on production
'NoneType' object is not iterable
Debug shows headers has None value while the csv file has headers in it.
headers:None
From
csvreader.fieldnamesdocumentation:So try reading the first row from the file, then
reader.fieldnamesshould contain the data you need. Maybe something like addingreader.next():The documentation also says:
So this difference in behaviour could be due to a difference in Python version between your two systems.