function is used to generate the input file Directory.txt his cell to gererate the file. rateinputFile(): lines='Springsteen, Bruce, 2587. \n', Hassan, lair, 6958. \n', 'ilones, Rebecca, Smith, John, 5252\n', MacDonald, Mirna, k9651 \n, Pichai, Sundar, 9612 Jobs, Steve, 1002\n, Goldsmith, Hicheal, 5478. \n, Yassir, Ammar, B8 "Pang Chee, 989n, Lee, Andrew, 7412. \n icholas. ck, 4600\n

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
7412
Andrew
6547
Dragos
# Bnd of directory ### #
Edt Metadata
[2]: M
** This function is used to generate the input file directory.txt
a* Run this cell to gererate the file.
def generateinputFile():
try:
lines-['Springsteen, Bruce, 2587. \n', Hassan, Aair, 69sa. \n', Homes, Rebecca, 5263n,
*Smith, John, 5252n, MacDonald, Mirna, 89651 \n, Pichai, Sundar, 9632. \n,
Jobs, steve, 1002 \n, Goldsmith, Hicheal, 5478. n, Yassir, Ammar, BSES \n,
Nicholas, Jack, 4G96\n','Pang, Chee, 9a98n, Lee, Andrew, 7412. \n,
*imenez, Dragos, 6547\n]
outfile open ("Directory,txt","w)
for line in lines:
outfile.write(1ine)
except Exception as ext
print (ex)
finally:
outfile.close()
generateinputFile()
Edt Metadata
In M
writefile Hito1. py
R MComment the above (ine after you finish your code, in order to generite the Python subwission file.
Transcribed Image Text:7412 Andrew 6547 Dragos # Bnd of directory ### # Edt Metadata [2]: M ** This function is used to generate the input file directory.txt a* Run this cell to gererate the file. def generateinputFile(): try: lines-['Springsteen, Bruce, 2587. \n', Hassan, Aair, 69sa. \n', Homes, Rebecca, 5263n, *Smith, John, 5252n, MacDonald, Mirna, 89651 \n, Pichai, Sundar, 9632. \n, Jobs, steve, 1002 \n, Goldsmith, Hicheal, 5478. n, Yassir, Ammar, BSES \n, Nicholas, Jack, 4G96\n','Pang, Chee, 9a98n, Lee, Andrew, 7412. \n, *imenez, Dragos, 6547\n] outfile open ("Directory,txt","w) for line in lines: outfile.write(1ine) except Exception as ext print (ex) finally: outfile.close() generateinputFile() Edt Metadata In M writefile Hito1. py R MComment the above (ine after you finish your code, in order to generite the Python subwission file.
The Directory.txt file contains names of the employees and their phone numbers in the following order:
Last nane, First name, Phone.
The creator of this fie made severai mistakes by typing commas and dots inconsistently.
Write a Python program to read this file and produce an output file with the name Oirectorytiow. txt This fle should format the phone directory as foloNs:
Phone
First name
Number 1
First name 1
Mumber 2
First nane 2
The fie MUST end with:
s une End of directory nen
Cot Metadaa
Edt Metadata
The output should be as follows
Content of the input file
rirst name
springsteen, Bruce, 2507.
Hansan, Aanir, 6958.
Homen, Rebecca, 5263
mith, John, 5252
MacDonald, Mirna, 89651
Pichai, undar, 9632.
Jobs, teve, 1002
Goldenith, Micheal, 5470.
Phone
2507
6958
5263
Bruce
Air
Rebecca
5252
John
8965
9632
1002
tundar
steve
Transcribed Image Text:The Directory.txt file contains names of the employees and their phone numbers in the following order: Last nane, First name, Phone. The creator of this fie made severai mistakes by typing commas and dots inconsistently. Write a Python program to read this file and produce an output file with the name Oirectorytiow. txt This fle should format the phone directory as foloNs: Phone First name Number 1 First name 1 Mumber 2 First nane 2 The fie MUST end with: s une End of directory nen Cot Metadaa Edt Metadata The output should be as follows Content of the input file rirst name springsteen, Bruce, 2507. Hansan, Aanir, 6958. Homen, Rebecca, 5263 mith, John, 5252 MacDonald, Mirna, 89651 Pichai, undar, 9632. Jobs, teve, 1002 Goldenith, Micheal, 5470. Phone 2507 6958 5263 Bruce Air Rebecca 5252 John 8965 9632 1002 tundar steve
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY