Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed
image text in transcribed
image text in transcribed
# 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

Explain the solution.

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago