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, 23.06.2019 09:00
The first screen you see when you open word2016 what is called?
Answers: 1
question
Computers and Technology, 23.06.2019 14:00
Technician a says that with self-adjusting clutch systems, the release bearing constantly rotates. technician b says that the ball bearing portion of the release bearing should be lubricated with high-temperature grease during routine maintenance. which technician is correct?
Answers: 2
question
Computers and Technology, 23.06.2019 18:00
Freya realizes she does not have enough in her bank account to use the debit card. she decides to use a credit card instead. which questions should freya answer before using a credit card? check all that apply. can i pay at least the minimum payment each month? can i make payments on time and avoid late fees? will i have to take out a loan? how much in finance charges can i afford to pay? should i talk to a consumer credit counseling service?
Answers: 1
question
Computers and Technology, 23.06.2019 20:00
What multimedia system creates an immersive, real-life experience that the user can interact with?
Answers: 1
You know the right answer?
Build_dict(reader) -> dictionary
this function accepts a csv reader as input and returns t...
Questions
question
Computers and Technology, 16.10.2019 01:10
question
Mathematics, 16.10.2019 01:20