The Directory.txt file contains names of the employees and their phone numbers in the following order:...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The Directory.txt file contains names of the employees and their phone numbers in the following order: Last name, First name, Phone. The creator of this file made several mistakes by typing commas and dots inconsistently. Write a Python program to read this file and produce an output file with the name DirectoryNew.txt. This file should format the phone directory as follows: Phone First name Number 1 Number 2 The file MUST end with: First name 1 First name 2 End of directory Content of the input file Springsteen, Bruce, 2587. Hassan, Amir, 6958. Homes, Rebecca, 5263 Smith, John, 5252 MacDonald, Mirna, 8965! Pichai, Sundar, 9632. Jobs, Steve, 1002 Goldsmith, Micheal, 5478. Yassir, Ammar, 8885 Nicholas, Jack, 4696 Pang, Chee, 9898 Lee, Andrew, 7412. Jimenez, Dragos, 6547 Edit Metadata The output should be as follows Phone 2587 6958 5263 5252 8965 9632 1002 5478 8885 4696 9898 7412 6547 First name Bruce Amir Rebecca John Mirna Sundar Steve Micheal Ammar Jack Chee Andrew Dragos Edit Metadata #### End of directory ########## In [ ]: M 1 ## This function is used to generate the input file Directory.txt 2 ## Run this cell to gererate the file. 6 7 8 10 11 12 13 14 15 16 # def generateInputFile(): try: lines=['Springsteen, Bruce, 2587.\n', 'Hassan, Amir, 6958. \n', 'Homes, Rebecca, 5263\n', 'Smith, John, 5252\n', 'MacDonald, Mirna, 8965! \n', 'Pichai, Sundar, 9632.\n', 'Jobs, Steve, 1002\n', 'Goldsmith, Micheal, 5478. \n', 'Yassir, Ammar, 8885\n', 'Nicholas, Jack, 4696\n', 'Pang, Chee, 9898\n', 'Lee, Andrew, 7412.\n', 'Jimenez, Dragos, 6547\n'] outfile = open("Directory. txt", 'w') for line in lines: outfile.write(line) except Exception as ex: print (ex) outfile.close() finally: 17 18 19 generateInputFile() Edit Metadata The Directory.txt file contains names of the employees and their phone numbers in the following order: Last name, First name, Phone. The creator of this file made several mistakes by typing commas and dots inconsistently. Write a Python program to read this file and produce an output file with the name DirectoryNew.txt. This file should format the phone directory as follows: Phone First name Number 1 Number 2 The file MUST end with: First name 1 First name 2 End of directory Content of the input file Springsteen, Bruce, 2587. Hassan, Amir, 6958. Homes, Rebecca, 5263 Smith, John, 5252 MacDonald, Mirna, 8965! Pichai, Sundar, 9632. Jobs, Steve, 1002 Goldsmith, Micheal, 5478. Yassir, Ammar, 8885 Nicholas, Jack, 4696 Pang, Chee, 9898 Lee, Andrew, 7412. Jimenez, Dragos, 6547 Edit Metadata The output should be as follows Phone 2587 6958 5263 5252 8965 9632 1002 5478 8885 4696 9898 7412 6547 First name Bruce Amir Rebecca John Mirna Sundar Steve Micheal Ammar Jack Chee Andrew Dragos Edit Metadata #### End of directory ########## In [ ]: M 1 ## This function is used to generate the input file Directory.txt 2 ## Run this cell to gererate the file. 6 7 8 10 11 12 13 14 15 16 # def generateInputFile(): try: lines=['Springsteen, Bruce, 2587.\n', 'Hassan, Amir, 6958. \n', 'Homes, Rebecca, 5263\n', 'Smith, John, 5252\n', 'MacDonald, Mirna, 8965! \n', 'Pichai, Sundar, 9632.\n', 'Jobs, Steve, 1002\n', 'Goldsmith, Micheal, 5478. \n', 'Yassir, Ammar, 8885\n', 'Nicholas, Jack, 4696\n', 'Pang, Chee, 9898\n', 'Lee, Andrew, 7412.\n', 'Jimenez, Dragos, 6547\n'] outfile = open("Directory. txt", 'w') for line in lines: outfile.write(line) except Exception as ex: print (ex) outfile.close() finally: 17 18 19 generateInputFile() Edit Metadata
Expert Answer:
Answer rating: 100% (QA)
Code in Python def generateInputFile try lines Springsteen Bruce 2587 Hassan Amir 6958 Homes Rebecca ... View the full answer
Related Book For
Management Accounting Information for Decision-Making and Strategy Execution
ISBN: 978-0137024971
6th Edition
Authors: Anthony A. Atkinson, Robert S. Kaplan, Ella Mae Matsumura, S. Mark Young
Posted Date:
Students also viewed these programming questions
-
3. (5 points) You write a call option with X-$40 and buy a call with X-$60. The options are on the same stock and have the same maturity date. One of the calls sells for $2 and the other for $9. a)...
-
Reviewing your corporation's statement of cash flows: what do you learn about your SEC 10-K company as you view the four financial statements together? Use course resources to explain the purpose of...
-
Principles of Community Engagement "Principles of Engagement, Second Edition" The fourth principle discusses "community empowerment". What does this term mean to you? Why is "empowerment" an...
-
A study of Machiavellian traits in accountants was published in Behavioral Research in Accounting (January 2008). Recall that Machiavellian describes negative character traits such as manipulation,...
-
Use the AC-3 algorithm to show that arc consistency is able to detect the inconsistency of the partial assignment {WA = red, V = blue} for the problem shown inFigure. NT WA Northern Territory...
-
A bookstore at the Hartsfield-Jackson Airport in Atlanta sells reading materials (paperback books, newspapers, magazines) as well as snacks (peanuts, pretzels, candy, etc.). A point-of-sale terminal...
-
A jogger runs in place on a treadmill whose belt moves at \(v_{\mathrm{EB} x}=+2.0 \mathrm{~m} / \mathrm{s}\) relative to Earth. Let the origins of the Earth reference frame and the reference frame B...
-
Joe obtained a box of antique Lenox china dishes that had been left at the Mashpee town dump. He supplemented the sizable but incomplete set of dishes with other Lenox pieces found at antique...
-
(a) The Treasury desk of a global bank incorporated in UK wants to invest GBP 200 million on 1st January, 2019 for a period of 6 months and has the following options: (1) The Equity Trading desk in...
-
Let P = (0.7, 100, 15) be a risky prospect. State 2 could be thought of as the occurrence of an accident which imposes a financial loss of 15 (figures could be thousands of euros). An insurance...
-
Petty cash is used to ________. Group of answer choices write checks for frequent purchases make small payments in cash avoid having to retain receipts because the amounts are very small avoid having...
-
In what way does the type of reward system known as payment by results differ from performance-related pay?
-
What steps can the business executive take to attract the attention of the target audience?
-
You have been offered a unique investment opportunity. If you invest $20,000 today, you will receive $1000 one year from now, $3000 two years from now, and $20,000 ten years from now. a. What is the...
-
You are considering purchasing a warehouse. The cost to purchase the warehouse is $492,000. Renting the equivalent space costs $19,700 per year. If the annual interest rate is 5.6%, at what rate must...
-
What are the diferences between the quantitative and non-quantitative approaches to job evaluation?
-
In the ocean near Hawaii (Northern Hemisphere :-)..), theprevailing winds are Trades. Taking into account the Ekmantransport, these winds will generate a net (integrated) water masstransport...
-
Ask students to outline the reasons why the various elements of culture (social structures and control systems, language and aesthetics, religion and other belief systems, educational systems, etc.)...
-
You are the controller of a chain of dry-cleaning establishments. You are computing the return on investment for each outlet. Outlet A, located in a city core, reported a net profit of $130,000. The...
-
What is the most motivating type of budget with respect to targets?
-
How can management accounting information produce behavioral and organizational reactions?
-
Mike's Veneer Shop owns a vacuum press that requires annual maintenance. Mike has a contract to cover the maintenance expenses for the next 5 years. The contract calls for an annual payment of \(\$...
-
True or False: The Consumer Price Index typically increases faster than the Higher Education Price Index.
-
Give four examples of goods or services that have exhibited inflation in recent years.
Study smarter with the SolutionInn App