1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Keith_Richards [23]
3 years ago
12

Read_data Define a function named read_data with two parameters. The first parameter will be a csv reader object (e.g., the valu

e 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 "smallDataFileWithoutHeaders.csv" you would write the following code: with open("smallDataFileWithoutHeaders.csv") as f_in: csv_r = csv.reader(f_in) result = read_data(csv_r,['tow_date','tow_reason']) 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_reason']) would need to return:

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

Computers and Technology
1 answer:
Sav [38]3 years ago
8 0

Answer:

Check the explanation

Explanation:

Given below is the code for the question. PLEASE MAKE SURE INDENTATION IS EXACTLY AS SHOWN IN IMAGE.

import csv

def read_data(csv_r, keys):

  data = []

  for row in csv_r:

      mydict = {}

      for i in range(len(keys)):

          mydict[keys[i]] = row[i]

      data.append(mydict)

  return data

SCREENSHOT:

You might be interested in
Most students overestimate their skill level and abilities to take open book tests.
leonid [27]
True...the assumption being that the student believes he/she will be able to locate the answer within the text rapidly, but they underestimate the fact that "application" of the content/question is primarily what the instructor is looking for, and will require critical thinking skills to apply the book content to the the question; not just "find the answer". 
3 0
3 years ago
Read 2 more answers
What are the uses of a modem
Vlada [557]

Modem provides internet, WiFi, we can connect multiple devices to internet through modem.

Modem provides radiation of short wavelength and the transmitter in your mobile phones and computers convert those radiations into digital signals and vice-versa.

5 0
3 years ago
Linda subscribes to a cloud service. The service provider hosts the cloud infrastructure and delivers computing resources over t
siniylev [52]

Answer

Public cloud

Explanation

A cloud service is any service that is made available to users who are on demand via internet from the cloud computing service providers.  These service providers have servers in their company premises where they offer the services from.

A public cloud is a type of computing in which a service provider makes resources available to the public via the internet. The service provider hosts the cloud infrastructure and delivers computing resources over the Internet Resources vary by provider but may include storage capabilities, applications or virtual machines.


3 0
4 years ago
A __________ is the column of data in a database that is used as the basis for arranging data.
Llana [10]
The answer is sort key.  A Sort Key is the column of data in a database that is used as the basis for arranging data. Iy is also used for rearranging data in the column.  An Operational Database is used to collect, modify, and maintain data on a daily basis.
8 0
3 years ago
Read 2 more answers
Why did latex replace wax?
andrezito [222]

Answer:

Latex replaced wax because it did the same thing and was used for the same things that wax would be used for

Explanation:

3 0
3 years ago
Other questions:
  • You have been asked to create an authentication security plan for your company. Which of the following components would you inco
    14·1 answer
  • How many megabytes of data can a factory made audio cd hold?
    13·1 answer
  • What is the 7 X 7 when referring to PowerPoint presentations?
    12·2 answers
  • What is an activity that can help you enhance the appearance of your computer’s desktop?
    13·1 answer
  • Some computer engineering students decided to revise the LC-3 for their senior project. In designing the LC-4, they decided to c
    13·1 answer
  • What video game has made the most money as of 2016?
    15·2 answers
  • What are interpersonal skills?
    12·2 answers
  • What are the first letters of each of the 3 main colors in javaScript? (seperate with commas)
    9·1 answer
  • Please help with this coding question
    8·2 answers
  • How many bytes/second is a 16Mbps cable modem connection?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!