Skip to content

Instantly share code, notes, and snippets.

@beauvais
Created October 20, 2011 23:16
Show Gist options
  • Save beauvais/1302689 to your computer and use it in GitHub Desktop.
Save beauvais/1302689 to your computer and use it in GitHub Desktop.
Python for tagging in CSV
# assign variable to a csv file read by csv.reader
csvFile = csv.reader(open('/Users/Zach/Desktop/survey.csv', 'rb'), delimiter=',')
# identify header row
header = next(csvFile)
# loop rows in csv file, and identify variables for fields
for row in csvFile:
if row[20] < 0:
continue
devStatus = row[4]
commercial = row[8]
industry = row[10]
usage = row[12]
address = row[14]
comment = row[20]
print comment
>>>
comment
comment
ine 25, in <module>
comment = row[20]
IndexError: list index out of range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment