Question

Consider the following file arrest.dat containing information of a suspect that the police is looking for:...

Consider the following file arrest.dat containing information of a suspect that the police is looking for:
arrest.dat:
The police is looking for Robert Whiteshead, also known as Whity, ID number 4607091111027, from address 4 Azalea Court, 219 Belmont Street, Germiston, 2065, in connection with a bank robbery at UNITED BANK in January 2016. An amount of about R45,000,000 was stolen on this day. Apparently he had a helper that goes by the name of JOINT13. Mr Whiteshead was also an accomplice in a car syndicate in 2015 in Somerset-West. If anybody can supply any information that could lead to his arrest, please contact Sgt SURPRISE MOLOI at the Germiston police station on 011-2336767 or 011-2336788.
Your task is to write a program that will read the above file character by character, change certain characters, and create an output file that is written character by character. The following changes to the input characters should be made:
All uppercase characters are ignored and not written
Change characters read from the file as follows:

The rest of the characters remain the same, and are just written to the output file without any change (except for uppercase characters that are ignored).
Create file arrest.dat and ask the user to input the input and output file names.
Display the contents of the input and the output file on the screen.
Extra work. Directly change the arrest.dat file.
You should paste your answer(s) here for the question number in the heading. Remember to keep the current font size.

Homework Answers

Answer #1
file1 = input("Enter input file name:-")
file2 = input("Enter output file name:-")#taking input from user

def file_read(file_name): # reading content of file
    f = open(file_name, 'r')
    ip_file_content = f.read()
    print (ip_file_content)
    f.close()

print("input file content")
file_read(file1)

with open(file1,'r') as f:
    letter = ""
    l = []
    while True:
        letter = f.read(1)   #one letter at a time
        if letter.isupper():  # checking upperCase letter or not
            continue          # skip if l;etter is upper case
        else:
            l.append(letter)  # lower case write in output
        f2 = open(file2,'w')

        f2.write(str(''.join(l)))
        if not letter:
           break

print("output file content")
file_read(file2)

for extra credit

give input and output file name as arrest.dat

Know the answer?
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
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • List and briefly explain each step in the ABCDE technique for examining irrational beliefs that contribute...
    asked 15 minutes ago
  • 1. Find the general solution of the first order linear differential equation: 2*x*dy/dx -y-3/sqrt(x)=0. sqrt() =...
    asked 37 minutes ago
  • Fairfield Homes is developing two parcels near Pigeon Fork, Tennessee. In order to test different advertising...
    asked 42 minutes ago
  • . For each of the following questions, say whether the random process is reasonably a binomial...
    asked 55 minutes ago
  • Please discuss why empathy is so important in light of current events. Please give specific examples
    asked 1 hour ago
  • Describe ONE thing you learned from either Peter singer or Tibor Machan author that compelled you...
    asked 1 hour ago
  • Global logistics firms such as DHL Supply Chain and Global Forwarding or C. H. Robinson Worldwide...
    asked 1 hour ago
  • Please match each factor in adoption of a new product or service to the best match...
    asked 1 hour ago
  • Fatty Acid Synthesis Assignment Explain how the activation of acetyl-CoA carboxylase prevents excess citrate in the...
    asked 1 hour ago
  • 1. Discuss and give an example of how a person might “constructively” enter a building of...
    asked 1 hour ago
  • Define the channel type for a natural trapezoidal dirt channel with a roughness of 0.045. The...
    asked 2 hours ago
  • Petroleum Production Engineering How can flow efficiency being improved without resulting into increasing water production?
    asked 2 hours ago