Last active
May 30, 2017 10:21
-
-
Save karlafej/7cd0f4cfd262847208f9b2bb56acde73 to your computer and use it in GitHub Desktop.
python_tip: csv.DictReader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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