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, 22.06.2019 16:20
It policy compliance and emerging technologies respond to the following: propose at least three control measures that organizations need to put in place to ensure that they remain complaint with emerging technologies and in a continually changing it environment. examine the correlation of effective configuration management and change control procedures to remain compliant with emerging technologies and it security changes.
Answers: 2
question
Computers and Technology, 22.06.2019 18:30
Which of the following commands is more recommended while creating a bot?
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
Acompany is hiring professionals for web designing. the firm is small with few resources. they want employees who possess problem-solving skills and can independently carry out responsibilities. which kind of employee should they select?
Answers: 2
question
Computers and Technology, 24.06.2019 08:00
Can someone work out the answer as it comes up in one of my computer science exams and i don't understand the cryptovariables
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
Mathematics, 07.05.2020 20:57
question
English, 07.05.2020 20:57
question
Mathematics, 07.05.2020 21:57
question
Mathematics, 07.05.2020 21:57
Questions on the website: 13722367