Skip to content

Instantly share code, notes, and snippets.

@ayota
Created June 14, 2014 17:06
Show Gist options
  • Save ayota/6063b75d67bfb2cd1865 to your computer and use it in GitHub Desktop.
Save ayota/6063b75d67bfb2cd1865 to your computer and use it in GitHub Desktop.
example of goal 2
codelist = ""
#this one splits the states.csv file
with open("states.csv","r") as states_file:
states = states_file.read().split("\n")
for index, state in enumerate(states):
states[index] = state.split(",")
#this formats the states in a pretty table
with open("statesexample.html","w") as states_file:
states_file.write('<table><tr><td>FULL NAME</td><td>ABBREVIATION</td></tr>')
for index,state in enumerate(states):
codelist += '<tr><td>{0}</td><td>{1}</td></tr>'.format(states[index][1],states[index][0])
states_file.write(codelist)
states_file.write('</table>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment