Skip to content

Instantly share code, notes, and snippets.

@karlafej
Last active May 30, 2017 10:21
Show Gist options
  • Save karlafej/7cd0f4cfd262847208f9b2bb56acde73 to your computer and use it in GitHub Desktop.
Save karlafej/7cd0f4cfd262847208f9b2bb56acde73 to your computer and use it in GitHub Desktop.
python_tip: csv.DictReader
import csv
with open('names.csv') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
print(row['first_name'], row['last_name'])
# If the column names suck you can provide a list yourself
# via the optional fieldnames in the DictReader constructor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment