Created
April 30, 2019 17:44
-
-
Save 8bitben/b69752bea220edb8acc9e5c1fb17e175 to your computer and use it in GitHub Desktop.
python-csv.py
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
''' | |
https://docs.python.org/3/library/csv.html | |
''' | |
import csv #import the required libraries | |
#open the file and assign it an identifier | |
with open('people.csv') as people: | |
#create a Dictionary Reader and pass the open file | |
my_csv_file = csv.DictReader(people) | |
#iterate the reader | |
for row in my_csv_file: | |
#preform actions with row content | |
print('My name is {}'.format(row['name'])) | |
print('I am {} years old'.format(row['age'])) | |
print('I live in {}'.format(row['location'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment