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
The MIQ inventory measures how much you value status. What are measures of status?
Alina [70]
When we're taking about measures of status, we're talking about either a socioeconomic perspective or something else. When we're talking about a socioeconomic perspective of status, there are two important measures. One would be social standing of a person and the other would be his economic standing. 
3 0
4 years ago
I'm asking more questions for help with schoolwork, thank you for the help, giving Brainliest.
r-ruslan [8.4K]
Give them brainliest!
4 0
3 years ago
You are looking for a backup that copies only the files that have changes since the last full backup. Which of the following wil
adelina 88 [10]

Answer: d. incremental backup

Explanation:

In incremental backup it copies only the files that have changed since the last full backup. It does not backup all the files just like the full backup. it however backup those copies into the  system which has changed since the last backup.

In doing  so it just increases the efficiency and performance of the backup procedure. This process is basically preferred when the amount of file to be backup is huge and there is not enough time to do a full backup.

Increment backup also use less disk space.

Cloud backup uses most increment backup for its application.

6 0
4 years ago
Write a brief explanation of the problems that can occur in each of the following scenarios and what you should do to avoid thes
photoshop1234 [79]
1. Horsing around can lead to breaking equipment in the classroom or somebody getting hurt

2. leaving your backpack on the floor can cause someone to fall

3.something unexpected may happen and worsen the problem

4. it can corrupt the computer's files and deleted unsaved work.

if you want the sentences to be longer, add some words to them and make the message the same.
4 0
4 years ago
Software that interprets commands from the keyboard and mouse is also knows as
adoni [48]
<span>Software that interprets commands from the keyboard and mouse is also known as Operating system.The Mouse will let you communicate and operate with the monitor in a computer.Not only mouse keyboard also plays the same role.But it is very easy to use rather than keyboard.sing MouseKeys can help someone move the pointer in smaller, controlled increments for better control</span>
6 0
3 years ago
Other questions:
  • Write a pseudocode that will take marks of physics, chemistry and math as input, calculates the average and displays output.
    7·2 answers
  • Given the following code:
    7·1 answer
  • How to calculate a pid controller
    8·1 answer
  • Here's another question!<br><br> What is some iterative programming structure uses?
    13·1 answer
  • When you cut and then paste a file, what are you doing?
    7·2 answers
  • 3. Write a program that inputs 4 hexadecimal digits as strings (example 7F), converts the string digits to a long – use strtol(i
    11·1 answer
  • An administrator wants to configure hosts to automatically assign IPv6 addresses to themselves by the use of Router Advertisemen
    14·1 answer
  • Given the following table of students, assignments, and grades for a single class:
    6·1 answer
  • During the data transmission there are chances that the data bits in the frame might get corrupted. This will require the sender
    8·1 answer
  • Explain external interface bus
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!