Your mission in this programming assignment is to create a Python program that will take an input file, determine if the contents of the file contain email addresses and/or phone numbers, create an output file with any found email addresses and phone numbers, and then create an archive with the output file as its contents. Tasks Your program is to accomplish the following: ‐ Welcome the user to the program ‐ Prompt for and get an input filename, a .txt file, from the user. ‐ Prompt for and get the desired output filename, a .txt file, from the user. ‐ Process the contents of the input file through email and phone number regular expressions. ‐ Write the pattern match results to the output file. ‐ Create a ZIP archive of the output file. ‐ Challenge. Can you get your phone regex to correctly process numbers in the (xxx)xxx‐xxxx format? Notes ‐ Hint. Use the textbook “Project: Phone Number and Email Address Extractor” on pp 165 – 169 as the core of your program. You know this code well from Programming Assignment 4. ‐ Hint. Be mindful of closing your various objects at the appropriate time. ‐ I will supply my own input file. In other words, I’m going to evaluate your program using my file. ‐ I will park your .py file in the same folder that my input file (.txt) is. Your program is to create the output file (.txt) and ZIP the files in the current working directory, which will be the same folder as the .py and .txt files are. No need to designate absolute or relative paths. ‐ Remember the P‐word? Pseudocode could be your friend in this assignment. I recommend you develop your algorithm via pseudocode before you put fingers to keyboard. ‐ Divide and Conquer. In your pseudocode, determine the major parts of the program. As you start to write source code, work on one piece at a time. Get that piece working and then move to the next piece.
Hint instructions on 165 - 169 below:
rint('Task I\nRegular Expression (Regex)')
print()
#! python3
# phoneAndEmail.py - Finds phone numbers and email addresses on the
clipboard.
import pyperclip, re
# Create phone number Regrex
phoneRegex = re.compile(r'''(
(\d{3}|\(\d{3}\))?
# area code
(\s|-|\.)?
# separator
(\d{3})
# first 3 digits
(\s|-|\.)
# Separator
(\d{4})
# last 4 digits
(\s*(ext|x|ext.)\s*(\d{2,5}))?
# extension
)''', re.VERBOSE)
# TODO: Create email regex
# TODO: Find matches in clipboard text.
# TODO: Copy results to the clipboard.
# phoneAndEmail.py - Finds phone numbers and email address on the
clipboard.
# Create email regex
emailRegex = re.compile(r'''(
[a-zA-Z0-9._%+-]+
# username
@
# @ symbol
[a-zA-Z0-9.-]+
# domain name
(\.[a-zA-Z]{2,4})
# dot-something
)''', re.VERBOSE)
# TODO: Find matches in clipboard text.
# TODO: Copy results to the clipboard
# phoneAndEmail.py - Find phone numbers and email.
# Find matches in clipboard text.
text = str(pyperclip.paste())
matches = []
for groups in phoneRegex.findall(text): # use for loop to fina
phone regex
phoneNum = '-'.join([groups[1], groups[3],
groups[5]]) # join phone numbers
if groups[8] != ' ':
phoneNum += ' x' +
groups[8]
matches.append(phoneNum) # add phone
number
for groups in emailRegex.findall(text): # use for loop to find all
email Regex
matches.append(groups[0]) # add and match
list
# TODO: Copy results to the clipboard
# phoneAndEmail.py - Finds phone numbers and email address on the clipboard.
for groups in emailRegex.findall(text):
matches.append(groups[0])
# Copy results to clipboard.
if len(matches) > 0:
pyperclip.copy('\n'.join(matches)) # use
pyperclip to copy the join clipboard
print('Copied to clipboard:') # print clipboard
copied to the screen
print('\n'.join(matches)) # print join matches
list to the screen
else:
print('No phone numbers or email addresses
found.') # print no phone or email to screen if not found
print()
Your mission in this programming assignment is to create a Python program that will take an...
Exercise 3) Creating a QT program to search for Customer Phone Number : Create a text file (customer.txt) and put names and phone numbers into it. each name has to have its own phone number right under it. In the QT window, the user has to enter a name and the program prints the phone number related to it. NB: If the user input a name that doesn't exist, the program should print an error message. Text file example: QT...
Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that uses iteration to guess a number from 1 to 10. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) a screenshot of the output, and 3) the Python program. Instructions Write pseudocode for a Python program that uses iteration to guess a number from...
Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs opening any of the 3 For example, (user input shown in caps in first line) Enter first...
please type code in Python find all the VALID email address in this input text file and store them as a single column of valid email addresses in an output text file labeled OutputFile First cut/paste the block of text below into a separate text file and label that data file InputFile: FinancialAid Email: [email protected] Scholarships Financial Aid Phone: 979-555-3236 Email: [email protected] Financial [email protected] Aid [email protected] Help Desk Central [email protected] Dean's Office Jill Educational Program Coordinator II Create...
USING RAPTOR For the following Programming Challenges, use the modular approach and pseudocode to design a suitable program to solve it. Create a program that allows the user to input a list of first names into one array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. The output should be a list of email addresses where the address is of the following from: [email protected]
In Python Provide me with your code file, output file and the text file Create a file having different integers than the first one. Save it as numbers1. txt . Write a program that reads all the number and calculates their average. Important: The two files that you are creating will contain different numbers.
Python 3.7 Coding assignment This Program should first tell users that this is a word analysis software. For any user-given text file, the program will read, analyze, and write each word with the line numbers where the word is found in an output file. A word may appear in multiple lines. A word shows more than once at a line, the line number will be only recorded one time. Ask a user to enter the name of a text file....
a. Provide me with your code file, output file and the text file. 1. Create a file with a series of integers. Save it as numbers. txt. Write a program that reads all the numbers and calculates their sum . 2. Create a file having different integers than the first one. Save it as numbers1. txt . Write a program that reads all the number and calculates their average. Important: The two files that you are creating will contain different...
C++ There are to be two console inputs to the program, as explained below. For each input, there is to be a default value, so that the user can simply press ENTER to accept any default. (That means that string will be the best choice of data type for the console input for each option.) The two console inputs are the names of the input and output files. The default filenames are to be fileContainingEmails.txt for the input file, and...
C++ (1) Write a program to prompt the user for an input and output file name. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs. For example, (user input shown in caps in first line, and in second case, trying to write to a folder which you may not have write authority in) Enter input filename: DOESNOTEXIST.T Error opening input file: DOESNOTEXIST.T...