Question: Write a program that will go through the lines in input.txt: a . If a line begins with From ( use regular expressions to find

Write a program that will go through the lines in input.txt:
a. If a line begins with From (use regular expressions to find the lines)
i. Extract the email address, day, date, month, year, and time (please note that there should be a space after the word From to avoid logic errors).
ii. Send the details to a csv file named output.csv with the help of csv methods. This output.csv file should be stored in the same location as the script file.
iii. The contents of your output.csv file should be identical to sample.csv (include the header row).
b. If a line begins with From: (use regular expressions to find the lines)
i. Extract the email address (please note that the colon is part of the word because there are lines that begin with From without a colon at the end).
ii. Keep track of how many times an email is sent from a particular address with the help of a dictionary.
iii. Send your dictionary results to an output file called output.txt.2. Write a program that will go through the lines in input.txt:
a. If a line begins with From (use regular expressions to find the lines)
i. Extract the email address, day, date, month, year, and time (please note that there should be a space after the word From to avoid logic errors).
ii. Send the details to a csv file named output.csv with the help of csv methods. This output.csv file should be stored in the same location as the script file.
iii. The contents of your output.csv file should be identical to sample.csv (include the header row).
b. If a line begins with From: (use regular expressions to find the lines)
i. Extract the email address (please note that the colon is part of the word because there are lines that begin with From without a colon at the end).
ii. Keep track of how many times an email is sent from a particular address with the help of a dictionary.
iii. Send your dictionary results to an output file called output.txt. This output.txt file should be stored in the same location as the script file.
iv. The contents of your output.txt file should be identical to sample.txt (include the last row showing total email count). This output.txt file should be stored in the same location as the script file.
iv. The contents of your output.txt file should be identical to sample.txt (include the last row showing total email count).

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!