Skip to content

Instantly share code, notes, and snippets.

@Peilonrayz
Created July 19, 2018 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Peilonrayz/c8c5ddbcdadcd4a1112c076c00043361 to your computer and use it in GitHub Desktop.
Save Peilonrayz/c8c5ddbcdadcd4a1112c076c00043361 to your computer and use it in GitHub Desktop.
import csv
def read_csv(path, headers=True)
with open(infile, newline='') as csvfile:
rows = csv.reader(csvfile)
if not headers:
yield from rows
else:
headers = next(rows)
for row in rows:
yield dict(zip(headers, row))
for row in read_csv('test.csv'):
print(row['birth.place'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment