subject
Engineering, 05.05.2020 23:07 ocean11618

Guidelines • You are not allowed to import anything. We know about the csv module, but you may not use it. • You are not allowed to use anything we haven't learned so far, including but not limited to: list comprehension, lambda functions, generators, builtins like zip(), etc. From built-in functions, you are not allowed to call sum(). Everything else is fair game. • You are allowed to use sets, dictionaries, and any of their respective operations. • You are allowed to use any string operations, including any way to format strings, except for string. find(), and string. replace() You can use any list operation, except for list. count() and list. sort() Do not hard code. Assignment The energy files are in the "csv" format, short for "comma separated values." These are just plain text files to represent a spreadsheet of information, where each piece of data is separated by a comma. The first row of each file is a description of what each column of information represents. Apart from the first column, the format of the header data is "Consumption. Sector. Energy" where Sector and Energy are replaced by one of several possible strings seen below. The possible economic sectors are (note the spaces): "Commercial", "Electric Power", "Industrial", "Refinery", "Residential", and "Transportation." The possible energy types are (note the spaces): "Coal", "Distillate Fuel Oil", "Geothermal", "Hydropower", "Kerosene", "Liquefied Petroleum Gases", "Other Petroleum Products", "Natural Gas", "Solar, "Wind", "Wood" State files A single state file contains the information for all years for the state given by the file name. Each line is one year's worth of comma separated data. The first line of a state file (the header) looks like this: Year, Consumption commercial. Coal 1, Consumption. Transportation. Natural Gas The header row tells you what each number in a particular line represents. The first number in a line of data in the state file is a year that data represents. The next number is the consumption in the "Commercial" sector for the "Coal" energy type. The last number in the line is the consumption in the "Transportation" sector for the "Natural Gas" energy type. The same idea applies to rest of the columns. Year files A single year file contains the information for all states for the year given by the file name. Each line is one state's worth of comma separated data. The first line of a year file (the header) looks like this: State, Consumption Commercial. coal,... Consumption. Transportation. Natural Gas The header row tells you what each number in a particular line represents, just like the state file. Functions The examples that you see here use the files that you are given to accompany this assignment. Make sure that when you test you either use the filename with a correct relative path to the csv file you are testing or you move the file you are testing to be in the same folder as your program. def summarize(filename): Description: Create a new file that contains a summary of the total consumption for three sectors: "Residential," "Commercial," and "Industrial." The summary is a per-line total of the consumption for all energy types of each sector. For each of the three sectors, calculate the sum of that sector's consumption in each line of the file. Write that sum to an output file in the appropriate column. You should write your output to a file, whose name is based on the original filename by adding "_summary" to the name. For example, if the input filename is "maryland. csv" then the output file should be called "maryland_summary. csv" The resulting file should have lines that look something like this (different for year files, where the leftmost column would be the states): Year, Consumption. Commercial, Consumption. Industrial, Consumption. Residential 1994,6787234,78849,610734 Parameters: filename, the name of an energy data file as described earlier. Return value: None, instead your result should be written to a file. Example output files for the following are included in the zipped files for this assignment. summarize('new_york. csv') < output in 'new_york_summary. csv' summarize('1977.csv') → output in '1977_summary. csv' summarize('virginia. csv') → output in 'virginia_summary. csv'

ansver
Answers: 1

Another question on Engineering

question
Engineering, 03.07.2019 14:10
Amass of 1.5 kg of air at 120 kpa and 24°c is contained in a gas-tight, frictionless piston-cylinder device. the air is now compressed to a final pressure of 720 kpa. during the process, heat is transferred from the air such that the temperature inside the cylinder remains constant. calculate the boundary work input during this process.
Answers: 2
question
Engineering, 04.07.2019 18:10
A-mn has a cubic structure with a0 0.8931 nm and a density of 7.47 g/cm3. b-mn has a different cubic structure, with a0 0.6326 nm and a density of 7.26 g/cm3. the atomic weight of manganese is 54.938 g/mol and the atomic radius is 0.112 nm. determine the percent volume change that would occur if a-mn transforms to b-mn.
Answers: 2
question
Engineering, 04.07.2019 18:10
Journeyman training is usually related (clo2) a)-to specific tasks b)-to cost analysis of maintenance task c)-to control process to ensure quality d)-to installation of machinery
Answers: 2
question
Engineering, 04.07.2019 18:20
Derive the correction factor formula for conical nozzle i=-(1+ cosa) and calculate the nozzle angle correction factor for a nozzle whose divergence hal-fangle is 13 (hint: assume that all the mass flow originates at the apex of the cone.
Answers: 3
You know the right answer?
Guidelines • You are not allowed to import anything. We know about the csv module, but you may not u...
Questions
question
Mathematics, 22.06.2021 08:20
question
Mathematics, 22.06.2021 08:20
question
Mathematics, 22.06.2021 08:30
question
Mathematics, 22.06.2021 08:30
question
Mathematics, 22.06.2021 08:30
Questions on the website: 13722359