Skip to content
Snippets Groups Projects
Commit c945875a authored by msyamkumar's avatar msyamkumar
Browse files

Lecture 14 notebooks

parent 5adb9b01
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ def __init__(): ...@@ -5,7 +5,7 @@ def __init__():
import csv import csv
"""This function will read in the csv_file and store it in a list of dictionaries""" """This function will read in the csv_file and store it in a list of dictionaries"""
__student__.clear() __student__.clear()
with open('cs220_survey_data.csv', mode='r') as csv_file: with open('cs220_survey_data.csv', mode='r', encoding='utf-8') as csv_file:
csv_reader = csv.DictReader(csv_file) csv_reader = csv.DictReader(csv_file)
for row in csv_reader: for row in csv_reader:
__student__.append(row) __student__.append(row)
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
...@@ -5,7 +5,7 @@ def __init__(): ...@@ -5,7 +5,7 @@ def __init__():
import csv import csv
"""This function will read in the csv_file and store it in a list of dictionaries""" """This function will read in the csv_file and store it in a list of dictionaries"""
__student__.clear() __student__.clear()
with open('cs220_survey_data.csv', mode='r') as csv_file: with open('cs220_survey_data.csv', mode='r', encoding='utf-8') as csv_file:
csv_reader = csv.DictReader(csv_file) csv_reader = csv.DictReader(csv_file)
for row in csv_reader: for row in csv_reader:
__student__.append(row) __student__.append(row)
...@@ -26,28 +26,30 @@ def get_age(idx): ...@@ -26,28 +26,30 @@ def get_age(idx):
return __student__[int(idx)]['Age'] return __student__[int(idx)]['Age']
def get_primary_major(idx): def get_major(idx):
"""get_primary_major(idx) returns the primary major of the student in row idx""" """get_major(idx) returns the major of the student in row idx"""
return __student__[int(idx)]['Primary major'] return __student__[int(idx)]['Major']
def get_other_majors(idx):
"""get_other_majors(idx) returns the secondary major of the student in row idx"""
return __student__[int(idx)]['Other majors']
def get_zip_code(idx): def get_zip_code(idx):
"""get_zip_code(idx) returns the residential zip code of the student in row idx""" """get_zip_code(idx) returns the residential zip code of the student in row idx"""
return __student__[int(idx)]['Zip Code'] return __student__[int(idx)]['Zip Code']
def get_latitude(idx):
"""get_latitude(idx) returns the latitude of the student's favourite place in row idx"""
return __student__[int(idx)]['Latitude']
def get_longitude(idx):
"""get_longitude(idx) returns the longitude of the student's favourite place in row idx"""
return __student__[int(idx)]['Longitude']
def get_pizza_topping(idx): def get_piazza_topping(idx):
"""get_piazza_topping(idx) returns the preferred pizza toppings of the student in row idx""" """get_piazza_topping(idx) returns the preferred pizza toppings of the student in row idx"""
return __student__[int(idx)]['Pizza topping'] return __student__[int(idx)]['Pizza topping']
def get_pet_owner(idx): def get_pet_owner(idx):
"""get_pet_owner(idx) returns whether student in row idx is a pet owner""" """get_pet_owner(idx) returns the pet preference of student in row idx"""
return __student__[int(idx)]['Pet owner'] return __student__[int(idx)]['Pet preference']
def get_runner(idx): def get_runner(idx):
"""get_runner(idx) returns whether student in row idx is a runner""" """get_runner(idx) returns whether student in row idx is a runner"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment