Question: A. Create a folder named 'tests', and download the attached file 'userinput.txt.' into the 'files' folder. (The attached file 'userinput.txt' is https://www.py4e.com/code3/mbox.txt) B. Now, create

A. Create a folder named 'tests', and download the attached file 'userinput.txt.' into the 'files' folder. (The attached file 'userinput.txt' is https://www.py4e.com/code3/mbox.txt)

B. Now, create a program IN PYTHON that will go through the 'userinput.txt' file.

REQUIREMENTS

1. In 'userinput.txt.', if a line starts with 'From:'

- Extract the email address

- Track how many times someone sent an email from a specific address by using a dictionary

- Forward the results of the dictionary to 'email.csv' AND total the # of emails at the bottom. This file should not be stored in the folder 'tests'

2. In 'userinput.txt', if a line starts with 'X-DSPAM-Confidence:'

- Send results to a file named 'confidence.txt'. Store this in the folder 'tests'

- Add the floating point number on the lines to a running total

- Also display the DSPAM confidence value total and average at the bottom of the file to 2 decimals

3. Keep in mind

- Use regular expressions to extract the lines

- Open output files in write mode, avoid append mode

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!