Question: Load the pipe-delimited file P. It is organized with 3 fields on each line: firstname|lastname|birthday. Search for the firstname F and the lastname L, replacing

Load the pipe-delimited file P. It is organized with 3 fields on each line: firstname|lastname|birthday.
Search for the firstname F and the lastname L, replacing the Birthday with B. Write the file back out in the same pipe-delimited format.
 Load the pipe-delimited file P. It is organized with 3 fields
on each line: firstname|lastname|birthday. Search for the firstname F and the lastname
L, replacing the Birthday with B. Write the file back out in

# Get the filepath from the command line import sys 4 P sys.argv[1] 3 5 F= sys.argv[2] 6 7B- sys.argv[4] L- sys.argv[3] 18 11 # Our Helper functions: 12 13 14 15 16 # Loads the file at filepath # Returns a 2d array with the data 18 19def load2dArrayFromFile(filepath): 20 # Your code goes here: 1with open (filepath, 'r) as rfile: 21- Lines rfile.read).split(n') while in lines: 23 lines.remove() 24 25 26 loadedArray [line . split('I') for line in lines] rfile.close () return LoadedArray 28 29 39 # Searches the 2d array , records, for firstname, lastname. # Returns the index of the record or-1, if no record exists 32 def findIndex (records, firstname, Lastnane): # Your code goes here: for line in records: 34 35 36 if firstname s linete] and lastname line13: return records.index (1ine) return-1 # Sets the birthday of the record at the given index * Returns: nothing 40def setBirthday (records, index, newBirthday): 41 # Your code goes here: Line records [index] Line[2]newBirthday records[index]line 42 45 46 47 def makeTextFrom2dArray (records) : # Convert the 2d array back into a string # Return the text of the 2d array # Your code goes here: writer We are very sorry, but o 63% (52:18)

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!