Created
June 14, 2014 17:06
-
-
Save ayota/6063b75d67bfb2cd1865 to your computer and use it in GitHub Desktop.
example of goal 2
This file contains hidden or 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
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