Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Make a folder called 'binder' and place 'lab.txt' in it. ('lab.txt' is https://www.py4e.com/code3/mbox.txt) 2. Create a Python program to: - Ask for user input

1. Make a folder called 'binder' and place 'lab.txt' in it. ('lab.txt' is https://www.py4e.com/code3/mbox.txt)

2. Create a Python program to:

- Ask for user input for the file name 'lab.txt' (for a file that's missing, use exceptions)

- When the proper file name is given 'lab.txt', open an output file named 'lab.csv' and store it in the folder 'binder'. Use os.path to check if the output file already exists in the folder. If it already exists, prompt the user to either overwrite it or create a different output file. Use 'y/n' for user input and 'w' if chosen to overwrite.

- When 'lab.csv' is created, find lines in 'lab.txt' that begin with:

- "From:" - email extract (for example, ONLY 'louis@media.berkeley.edu')

- "Subject:" - number extract (for example, ONLY 'r39757')

- "X-DSPAM-Confidence:" value extract (for example, ONLY '0.6932')

- Place these results in 'lab.csv' for EVERY time one of these shown above and give them headers of 'Email', 'Subject', and 'Value'

- When the data has been transferred to 'lab.csv', print 'The data has been successfully stored!' and finish the program

3. Note:

- When getting user input for the file name, strip input and do not lower

- Use functions if you want

SAMPLE OUTPUT

Please input the file: new.txt

That file does not exist.

Please input the file: lab.txt

Please state the output: lab.csv

The data has been successfully stored!

SAMPLE OUTPUT

Please input the file: new.txt

That file does not exist.

Please input the file: lab

That file does not exist.

Please input the file: lab.txt

Please state the output: lab.csv

File already exists. Overwrite (y/n)?: z

Please enter (y/n): b

Please enter (y/n): N

What is the new output: lab.csv

File already exists. Overwrite (y/n)?: n

What is the new output: new.csv

The data has been successfully stored!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions

Question

consider how qualitative data can add value to your research;

Answered: 1 week ago

Question

1. Television more Over watching faceing of many problems ?

Answered: 1 week ago

Question

Is there a link between chronic stress and memory function?

Answered: 1 week ago