p5 -...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#http://manyeyes.alphaworks.ibm.com/manyeyes/visualizations/3a57d6b8ce7111de975d000 255111976/comments/3a5b1206ce7111de975d000255111976 #IMPORT DATA Statepopulations=open("StatePopulations.txt", "r") Energysources=open("EnergySources.csv", "r") #BUILD DICTIONARIES PopulationDict={} EnergyDict={} for line in Statepopulations: StatePopulations = line.split() if StatePopulations == []: continue if StatePopulations[0] != "n/a": if len(StatePopulations) == 11: StateName= StatePopulations[2] Population= StatePopulations[3] else: StateName= StatePopulations[2]+" "+StatePopulations[3] Population= StatePopulations[4] #ASSIGN DATA TO DICTIONARY Population=Population.replace(",","") PopulationDict[StateName]= Population Statepopulations.close() for line in Energysources: EnergySources= line.split(",") if EnergySources[0] not in PopulationDict: continue StateName=EnergySources[0] Coal= EnergySources[1] NaturalGas= EnergySources[2] Petroleum= EnergySources[3] Nuclear= EnergySources[4] Hydroelectric= EnergySources[5]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/21/2010 for the course ECS 40175 taught by Professor Amenta during the Fall '09 term at UC Davis.

Page1 / 2

p5 -...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online