I have a set of csv headers that I am trying to match with uploads. It's not really working. Not all headers are required -- I just have to match what's in the file.
reader = csv.DictReader(open(PathFile))
headers = reader.fieldnames
for header in sorted(set(headers)):
if (header == 'ip') or (header == 'IP'):
print "IP found in Header"
In this case, IP is not found.
for row in reader:
if row.get('IP'):
print "IP found in Row"
It's not found again. I did search on this site -- there was:
IP = row.get('IP', None)
That did not work either.
This is the file I'm using for testing:
Email, IP, Name, City, State, zip, country, garbage
[email protected], 34.4.34.34,Mr GH, chicago, il ,60601, us,erw ewr
[email protected], 34.45.23.34, Mr 5t,NY,NY,10101, us, er