## This function is used to generate the input file Directory.txt # 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) finally: outfile.close() generateInputFile() use this code to get the file and please match the answer with the sample run

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

## This function is used to generate the input file Directory.txt

#

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)
finally:
outfile.close()
generateInputFile()

use this code to get the file and please match the answer with the sample run

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
First name 1
Number 2
First name 2
The file MUST end with:
########## End of directory ##########
Edit Metadata
Edit Metadata
Content of the input file
The output should be as follows
Phone
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,
Nicholas, Jack,
Pang, Chee, 9898
Lee, Andrew, 7412.
Jimenez, Dragos,
First name
2587
6958
5263
Bruce
Amir
Rebecca
5252
8965
9632
John
Mirna
Sundar
1002
5478
8885
4696
9898
Steve
8885
Micheal
4696
Ammar
Jack
Chee
6547
7412
Andrew
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 First name 1 Number 2 First name 2 The file MUST end with: ########## End of directory ########## Edit Metadata Edit Metadata Content of the input file The output should be as follows Phone 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, Nicholas, Jack, Pang, Chee, 9898 Lee, Andrew, 7412. Jimenez, Dragos, First name 2587 6958 5263 Bruce Amir Rebecca 5252 8965 9632 John Mirna Sundar 1002 5478 8885 4696 9898 Steve 8885 Micheal 4696 Ammar Jack Chee 6547 7412 Andrew
Edit Metadata
Edit Metadata
Content of the input file
The output should be as follows
Springsteen, Bruce, 2587.
Hassan, Amir, 6958.
Homes, Rebecca, 5263
Smith, John, 5252
MacDonald, Mirna, 8965!
Pichai, undar,
Jobs, Steve, 1002
Goldsmith, Micheal, 5478.
Yassir, Ammar, 8885
Nicholas, Jack, 4696
Pang, Chee, 9898
Lee, Andrew, 7412.
Jimenez,
Phone
First name
2587
6958
Bruce
Amir
5263
5252
8965
9632
1002
5478
8885
4696
9898
7412
Rebecca
John
9632.
Mirna
Sundar
Steve
Micheal
Ammar
Jack
Chee
Dragos, 6547
Andrew
6547
Dragos
##3# End of directory
#3%23
1] :
Edit Metadata
Transcribed Image Text:Edit Metadata Edit Metadata Content of the input file The output should be as follows Springsteen, Bruce, 2587. Hassan, Amir, 6958. Homes, Rebecca, 5263 Smith, John, 5252 MacDonald, Mirna, 8965! Pichai, undar, Jobs, Steve, 1002 Goldsmith, Micheal, 5478. Yassir, Ammar, 8885 Nicholas, Jack, 4696 Pang, Chee, 9898 Lee, Andrew, 7412. Jimenez, Phone First name 2587 6958 Bruce Amir 5263 5252 8965 9632 1002 5478 8885 4696 9898 7412 Rebecca John 9632. Mirna Sundar Steve Micheal Ammar Jack Chee Dragos, 6547 Andrew 6547 Dragos ##3# End of directory #3%23 1] : Edit Metadata
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Stack operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT