Question: Complete the function parse _ file ( ) . This function takes a file name as a parameter, reads the file line by line and

Complete the function parse_file(). This function takes a file name as a parameter, reads the file line by line and
creates a data structure to represent the input. The structure has the following format: at the top it is a pair. The
first element of the pair is a list of names (the participants) in the order given in the file. The second element of the
pair is a list of pairs; each list cell will correspond to a given day.
Within each list-pair, the first element should be a dictionary whose keys are the names of those tested for vampirism
and whose values are the Booleans True (that is, a vampire, indicated by V in the input file) or False (that is, a
human). The second element of a list-pair is a list of lists, with each outer list-element being an inner list of those
groups who were in contact on that day. After you finish processing the file, make sure to close it, and then return
the structure youve created. Heres the structure wed expect for the sample file given above, as printed by Python:
(['Bella', 'Edward', 'Jacob', 'Carlisle', 'Alice', 'Emmett', 'Charlie',
'Renee', 'Jessica', 'Angela'],[({'Edward': True, 'Bella': False, 'Jacob':
False, 'Jessica': False},[['Bella', 'Edward'],['Charlie', 'Jacob'],
['Alice', 'Renee']]),({'Bella': False, 'Jacob': False, 'Alice': True,
'Charlie': False},[['Bella', 'Edward', 'Charlie'],['Angela', 'Jessica']]),
({'Emmett': True, 'Renee': False, 'Jessica': True},[]),({'Bella': True,
'Charlie': False},[['Bella', 'Edward', 'Charlie', 'Jessica', 'Angela'],
['Jacob',
'Renee']])])
If the file isnt somehow formatted correctly for example, if one of the numbers isnt a number when you convert it
to an integer then print the error message

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!