Engineering
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'

answer
Answers: 1

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 16:10, Arealbot
The force on a cutting tool are 2600n vertically downward and 2100 horizontal. determine the resultant force acting on the tool and the angle at which it acts.
Answers: 1
image
Engineering, 04.07.2019 18:10, xboxdude06
Slip occurs via two partial dislocations because of (a) the shorter path of the partial dislocation lines; (b) the lower energy state through partial dislocations; (c) the charge balance.
Answers: 1
image
Engineering, 04.07.2019 18:20, cdyshaylia55
Water vapor initially at 10 bar and 400 °c is contained within a piston-cylinder assembly. the water lost heat to the surrounding according to isochoric (iso-volumetric) process until its temperature is 150 °c. the water is then condensed isothermally to saturated liquid. for the water as a system, calculate the work in kj/kg
Answers: 2
image
Engineering, 04.07.2019 19:10, gabigalvis1091
What is the main objective of using reheat rankine cycle?
Answers: 3
Do you know the correct answer?
Guidelines • You are not allowed to import anything. We know about the csv module, but you may not u...

Questions in other subjects:

Konu
Mathematics, 22.12.2020 01:10
Konu
English, 22.12.2020 01:10