Question

B Codio - IT-140-R5545 Intro Mail - thon a https://codio.com/twinters/file-handling:5cb76949180630 Codio Project File Edit Fi
enge: Fixed Length Records You will be passed the filename P, firstname F, lastname L and a new birthday B Load the fixed len
B Codio - IT-140-R5545 Intro Mail - thon a https://codio.com/twinters/file-handling:5cb76949180630 Codio Project File Edit Find View Tools Education Help ngth-.. # 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] # Your Code Goes Here open (P, "r") f.readlines () f lines f.close() f- open (P, "a") for line in lines: line[:16].strip() and L = line[16:32].strip () : if F == print ("%16s%16s%16s "% ( F, L, B) ) else: print (line) f.close) Pytho
enge: Fixed Length Records You will be passed the filename P, firstname F, lastname L and a new birthday B Load the fixed length record file in P, search for F, L in the first and change birthday to B Hint: Each record is at a fixed length of 16. Then save the file. Check It LAST RUN on 6/11/2019 11 19:01 PM X Program Output Program Failed for Input:/tmp/fixed1 Adam Smithers 00000000 Expected Output Smith Your Program Output: Adam Anderson 11111985Theodore Biscuit-Barrel 03201990Monty Smithers 10181980Adam Anderson 10101960Ruthy 1121 P 06062010 d 6/11/20
0 2
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

import sys 1 P = sys.argv[1] F = sys.argv[2] L sys.argv[3] 4 sys.argv[4] 5 B = f = open(P, r) f.readlines(). lines 7 f.clos

Code:

import sys

P = sys.argv[1]

F = sys.argv[2]

L = sys.argv[3]

B = sys.argv[4]

f = open(P, "r")

lines = f.readlines()

f.close()

f = open(P, "w")

for line in lines:

line = line.strip()

if F==line[:16].strip() and L ==line[16:32].strip():

print("%-16s%-16s%-16s"%(F,L,B), file=f)

else:

print(line, file=f)

f.close()

Add a comment
Know the answer?
Add Answer to:
B Codio - IT-140-R5545 Intro Mail - thon a https://codio.com/twinters/file-handling:5cb76949180630 Codio Project File Edit Find View...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • #Get the filepath from the command line import sys P= sys.argv[1] F= sys.argv[2] L= sys.argv[3] B=...

    #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: 1 2 23 # # Searches the 2d array 'records' for firstname, lastname. # Returns the index of the record or -1 if no record exists 24 25 # def findIndex ( records, firstname, lastname)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT