Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will be passed the filename P, firstname F, lastname L, and a new birthday B. Hint: Each record is at a fixed length of

You will be passed the filename P, firstname F, lastname L, and a new birthday B.
Hint: Each record is at a fixed length of 16.
Then save the file.
image text in transcribed
image text in transcribed
# Get the filepath from the command line import sys P- sys.argv[1] F- sys.argv[2] sys.argv[3] B- sys.argv[4] # Your Code Goes Here files open(P, 'r') recordlines - files.readline () info list [l first-index last index 40 cur-line recordlines [first-index : last-index) while ten(cur line) 0: firstname-cur lineto:16] Lastname cur line[16:32] birthdate cur line[32:40] if (firstname . strip() F) and (lastname . strip() L): birthdate-B resfirstname + Lastname + birthdate info list.append (res) first index - first index 40 last index last index +40 cur-line recordlines [first-index : last-index] files.close () files = open ( P , , w , ) for i in info list: files.write(i) files.close )

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

KEY QUESTION Refer to the table in question

Answered: 1 week ago