subject

Variable Length Record

Load the pipe-delimited file P. It is organized with 3 fields on each line: firstname|lastname|birthday.

Search for the firstname F and lastname L, replacing the birthday with B. Write the file back out in the same pipe-delimited format.

Given Code:

# Get the filepath from the command line
import sys
P= sys. argv[1]
F= sys. argv[2]
L= sys. argv[3]
B= sys. argv[4]

#
#
# Our Helper functions:
#
#

#
# Loads the file at filepath
# Returns a 2d array with the data
#
def load2dArrayFromFile(filepath):
# Your code goes here:

#
# Searches the 2d array 'records' for firstname, lastname.
# Returns the index of the record or -1 if no record exists
#
def findIndex(records, firstname, lastname):
# Your code goes here:

# Sets the birthday of the record at the given index
# Returns: nothing
def setBirthday(records, index, newBirthday):
# Your code goes here:

# Convert the 2d array back into a string
# Return the text of the 2d array
def makeTextFrom2dArray(records):
# Your code goes here:

#
#
# Our main code body, where we call our functions.
#
#

# Load our records from the file into a 2d array
records= load2dArrayFromFile(P)

# Find out which index, if any, has the name we are hunting
indexWeAreHunting= findIndex(records, F, L)

# Set the birthday record to the one we were passed
setBirthday(records, indexWeAreHunting, B)

# Convert the records into a text string
output= makeTextFrom2dArray(records)

# Your code goes here
# write the text string out to the file

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:30
This isn’t really school related, but like where the heck can you find manga, to read to where you don’t have to pay money, for points? my friend wants me to read bj alex, and i can’t find it anywhere for free.
Answers: 2
question
Computers and Technology, 22.06.2019 23:30
What does 21 pilots middle aged name as a band 15 years prior to them naming their band 21 pilots?
Answers: 1
question
Computers and Technology, 23.06.2019 10:50
The volume v and paper surface area a of a conical paper cup are given by where r is the radius of the base of the cone and h is the height of the cone. a. by eliminating h, obtain the expression for a as a function of r and v. b. create a user-de ned function that accepts r as the only argument and computes a for a given value of v. declare v to be global within the function. c. for v ! 10 in.3 , use the function with the fminbnd function to compute the value of r that minimizes the area a. what is the corresponding value of the height h? investigate the sensitivity of the solution by plotting v versus r. how much can r vary about its optimal value before the area increases 10 percent above its minimum value?
Answers: 1
question
Computers and Technology, 23.06.2019 17:30
Write pseudocode to represent the logic of a program that allows the user to enter a value. the program multiplies the value by 10 and outputs the result.
Answers: 1
You know the right answer?
Variable Length Record

Load the pipe-delimited file P. It is organized with 3 fields on...
Questions
question
Computers and Technology, 27.04.2021 19:40
question
Mathematics, 27.04.2021 19:40
Questions on the website: 13722362