subject

Read_data Define a function named read_data with two parameters. The first parameter will be a csv reader object (e. g., the value returned when calling the function csv. reader) and the second parameter will be a list of strings representing the keys for this data. The list matches the order of data in the file, so the second parameter's first entry is the key to use for data in the file's first column, the second parameter's second entry is the key to use for data in the file's second column, and so on. The function's first parameter will be a csv reader object and not a string. This means you do not need the with..as nor create the csv reader in your function, but this will be done in the code calling your function. For example, to execute read_data using a file named ".csv" you would write the following code: with open(".csv") as f_in: csv_r = csv. reader(f_in) result = read_data(csv_r,['tow_date','tow_re ason']) You would then want to include code to check that header had the expected value. The function should return a list of dictionaries. This list will contain a dictionary for each row read using the first parameter. The keys of these dictionaries will be the entries in the second parameter and the values will be the data read in from the file (you can assume there will be equal numbers list entries and columns).
For example, suppose the lines of the file being read by csv_r were:

2015-12-30,IL

2018-04-07,GA

then the call read_data(csv_r,['tow_date','tow_re ason']) would need to return:

[{'tow_date': '2015-12-30', 'tow_reason': 'IL'},
{'tow_date': '2018-04-07', 'tow_reason': 'GA'}]

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 12:10
Linux is distributed under gnu gpl. why is this important? a. it ensures that only torvalds can profit from the sale of linux b. it prevents unknowledgeable users from downloading programs they don't know how to operate. c. it provides protection for the developers who created linux. d. it states that anyone can copy, modify, and share the program if changes are made public.
Answers: 1
question
Computers and Technology, 23.06.2019 15:20
In a game with three frames, where will the objects on layer 1 appear? a. next to the play area b. in the middle of the game c. behind everything else d. in front of everything else
Answers: 1
question
Computers and Technology, 24.06.2019 00:10
Read each statement below. if the statement describes a peer-to-peer network, put a p next to it. if the statement describes a server-based network, put an s next to it. p - peer-to-peer s - server-based
Answers: 1
question
Computers and Technology, 24.06.2019 06:30
For which utilities, if any, does the landlord pay?
Answers: 2
You know the right answer?
Read_data Define a function named read_data with two parameters. The first parameter will be a csv r...
Questions
Questions on the website: 13722363