subject

Build_dict(reader) -> dictionary
this function accepts a csv reader as input and returns the required dictionary. it iterates over the csv reader and with each iteration, extracts the needed data and remove any extra whitespaces. you need to skip the header line before start reading the data:

next(reader, none)
the data to be extracted is:

entity - index 0 (string)
records lost - index 2 (int)
year - index 3 (int)
story - index 4 (string)
sector – index 5 (string)
method - index 6 (string)
news sources - index 11 (list of strings)

valid data checks:

if there are multiple news sources at index 11, they will be separated by a comma (‘,’).

these should all be stored in a list. if the news sources field is empty ignore that line.

treat all missing numeric values of "records lost" as a 0. you need to remove all

occurrences of ‘,’ in the records lost before converting to integer. hint: use

.replace()

if any of these pieces of data is missing (other than "records lost"), e. g. the field is empty or spaces, ignore that line of data.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 20:40
Peripherals are part of the main computer. true false
Answers: 3
question
Computers and Technology, 22.06.2019 04:30
Ryan is working on the layout of her web page. she needs to figure out where her header, navigation bar, text, and images should go. what technique can her?
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
Which location-sharing service offers items for users as a gaming component and also allows them to collectively link their check-ins to publish a trip? a. whrrl b. buzzd c. foursquare (this option is wrong i already tried) d. gowalla for plato
Answers: 2
question
Computers and Technology, 23.06.2019 06:30
You are consulting for a beverage distributor who is interested in determining the benefits it could achieve from implementing new information systems. what will you advise as the first step?
Answers: 1
You know the right answer?
Build_dict(reader) -> dictionary
this function accepts a csv reader as input and returns t...
Questions
question
Mathematics, 25.01.2022 01:00
question
Physics, 25.01.2022 01:00
question
Mathematics, 25.01.2022 01:00
question
Mathematics, 25.01.2022 01:00
question
Mathematics, 25.01.2022 01:00
Questions on the website: 13722362