Last active
October 12, 2019 13:05
-
-
Save jwestgard/2646939eb5e0bc204ee02ac7e288bd4d to your computer and use it in GitHub Desktop.
state class example
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
| import csv | |
| class State(): | |
| def __init__(self, row): | |
| self.abbrev = row["State"] | |
| self.mwh = row["Megawathours"] | |
| self.source = row["Energy Source"] | |
| self.year = row["Year"] | |
| def main(): | |
| fh = open('/Users/tmgre/Downloads/energy.csv') | |
| spreadsheet = csv.reader(fh) | |
| greatest_wind = None | |
| for row in spreadsheet: | |
| if row[2] == 'Wind': | |
| current_state = State(row) | |
| if greatest_wind is None or greatest_wind.mwh < current_state.mwh: | |
| greatest_wind = current_state | |
| elif row[2] == 'Solar Thermal and Photovoltaic': | |
| #### etc. #### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment