p5 -...

Info icon This 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] Biomass= EnergySources[6] Geothermal= EnergySources[7] InterstateImports= EnergySources[8] #ASSIGN DATA TO DICTIONARY EnergyDict[StateName]=[Coal,NaturalGas,Petroleum,Nuclear,Hydroelectric,Biomass,
Image of page 1

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern