Skip to content

Instantly share code, notes, and snippets.

@cigrainger
Created December 14, 2013 20:59
Show Gist options
  • Save cigrainger/7964831 to your computer and use it in GitHub Desktop.
Save cigrainger/7964831 to your computer and use it in GitHub Desktop.
import csv
f = open('students.csv').read()
while f.split('\n')[0] != 'name,email':
morecsv = raw_input("This does not look like the correct file. Would you like to see more? y/n?")
while morecsv != 'y' or 'n':
morecsv = raw_input("The prompt was y/n only. Would you like to see more? y/n?")
if morecsv == 'y':
print f.split('\n')[:10]
newcsv = raw_input("Would you like to overwrite this file to create the student list? y/n?")
while newcsv != 'y' or 'n':
newcsv = raw_input("y/n only. Would you like to overwrite this file to create the student list?")
if newcsv == 'y':
f.truncate()
f.write('name,email')
if newcsv == 'n':
return 'Okay. Goodbye.'
elif morecsv == 'n':
return 'Okay. Goodbye.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment