Last active
December 31, 2015 08:09
-
-
Save cigrainger/7958700 to your computer and use it in GitHub Desktop.
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 pandas as pd | |
students = pd.read_csv('students.csv') | |
def newstudent(x): | |
newname = raw_input("What is the student's name? ") | |
newemail = raw_input("What is the student's email address? ") | |
newrow = [{'name':newname,'email':newemail}] | |
df = x.append(newrow, ignore_index=True) | |
return df | |
def addstudent(x): | |
newdf = newstudent(x) | |
again = raw_input("Do you want to add another student? y/n? ") | |
if again == 'y': | |
addstudent(newdf) | |
elif again == 'n': | |
newdf.to_csv('students.csv', index=False) | |
return 'Done.' | |
else: | |
newdf.to_csv('students.csv', index=False) | |
return 'Prompt was y/n. Saving progress and quitting.' | |
addstudent(students) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment