Computers and Technology
Computers and Technology, 18.02.2020 21:54, jay13212

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

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 22:00, rd1369
Some of your friends have gotten into the burgeoning field of time-series data mining, in which one looks for patterns in sequences of events that occur over time. purchases at stock exchanges"what's being bought" are one source of data with a natural ordering in time. given a long sequence s of such events, your friends want an efficient way to detect certain "patterns" in them"for example, they may want to know if the four events buy yahoo, buy ebay, buy yahoo, buy oracle occur in this sequence s, in order but not necessarily consecutively. they begin with a collection of possible events (e. g., the possible transactions) and a sequence s of n of these events. a given event may occur multiple times in s (e. g., yahoo stock may be bought many times in a single sequence s). we will say that a sequence s is a subsequence of s if there is a way to delete certain of the events from s so that the remaining events, in order, are equal to the sequence s . so, for example, the sequence of four events above is a subsequence of the sequence buy amazon, buy yahoo, buy ebay, buy yahoo, buy yahoo, buy oracle their goal is to be able to dream up short sequences and quickly detect whether they are subsequences of s. so this is the problem they pose to you: give an algorithm that takes two sequences of events"s of length m and s of length n, each possibly containing an event more than once"and decides in time o(m + n) whether s is a subsequence of s.
Answers: 3
image
Computers and Technology, 21.06.2019 22:40, hePandaKing3689
State the parts of a variable declaration?
Answers: 2
image
Computers and Technology, 23.06.2019 10:30, badpotterchris
How would you categorize the software that runs on mobile devices? break down these apps into at least three basic categories and give an example of each.
Answers: 1
image
Computers and Technology, 23.06.2019 18:30, sawyerfauver
The computers in the sales department did not have enough data storage capacity to contain all the information the department needed to store, and it was taking a long time for team members to access the data they needed. to fix the problem, the technician installed new, larger hard drives on all the computers.
Answers: 1
Do you know the correct answer?
Variable Length Record

Load the pipe-delimited file P. It is organized with 3 fields on...

Questions in other subjects:

Konu
Mathematics, 25.02.2021 22:30