<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Lesson 29
Step1:  Text Importer
You can use pyperclip to copy and paste text to and from the clipboard, but this implementation will use PyPDF2 to deal with files in a local folder. 
All the files used in these exercises are available here, and are stored in this repository in the local files folder.
Step2:  Regex Extractions
Step3:  Format and Print Results
<ASSISTANT_TASK:>
Python Code:
# Import Regex Module
import re
## Create Phone Regex
# Basic Phone Number: 415-555-0000
# Phone Numeber without Area Code: 555-0000
# Phone Number with Parenthesis: (415)-555-5000
# Phone Numbers with Extensions: ext /ext. /x12345
phoneRegex = re.compile(
r'''
(                       # entire number (stored as its own group for .findall())
((\d\d\d)|(\(\d\d\d\))) # area code (optional, with and without parenthesis)
(\s|-)                  # first seperator (space or -)
\d\d\d                  # first 3 digits
-                       # second seperator
\d\d\d\d                # last 4 digits
(((ext(\.)?\s)|x))?     # extension word part (optional, as 'ext ', optional 'ext. ' or 'x')
((\d){2-5})?            # extension digit part (optional, with at least 2 or at most 5 digits)
)
''', re.VERBOSE)
# Much more readible in verbose mode than single mode
## Create Email Regex
# Basic Email: something@something.com
# Fancy Email: some.+_thing@something.com
# Alternate domain: something@some.+_thing.anywhere
emailRegex = re.compile(
r'''
[a-zA-Z0-9_.+]+ # name (Custom character class, one or more lowercase, uppercase, numbers and symbols)
@               # @ symbol
[a-zA-Z0-9_.+]+ # domain name (Custom character class, one or more lowercase, uppercase, numbers and symbols)
''', re.VERBOSE)
# Custom character classes do NOT require escaping characters
# Much more readible in verbose mode than single mode
Explanation: Lesson 29:
RegEx Example Program: A Phone and Email Scraper
This program will do the following:
Create RegEx for phone numbers
Create a RegEx for Email Address
Get the Text (Pyperclip or Requests)
Extract the email/phone from the text
Copy the extracted email/phone to the clipboard
Create RegEx Objects
End of explanation
import PyPDF2
## Example PyPDF2 Application
# An illustration of PyPDF2 functions
pdfFile = open('files/meetingminutes.pdf', 'rb') # Open the PDF file from the local folder in pdfFile
pdfReader = PyPDF2.PdfFileReader(pdfFile) # Store the PDF reader object in pdfReader
pageObject = pdfReader.getPage(0) # Get the zero page from the pdfReader object and store in the pageObject; PyPDF2 starts at 0 index
print(pageObject.extractText()) # Print extracted text from the zero page from the pageObject
pdfFile.close() # Close PDF file
## PDF 1: Phone Directory 
pdfFile1 = open('files/112065.pdf', 'rb') # Open the PDF file from the local folder in pdfFile
pdfReader1 = PyPDF2.PdfFileReader(pdfFile1) # Store the PDF reader object in pdfReader
print(pdfReader1.getNumPages()) # Print number of pages
pdf1PageText = [] # Create empty list object to store text
for page in range(0, pdfReader1.getNumPages()): # Loop through all PDF Pages
    newpdf1PageText = pdfReader1.getPage(page).extractText() # Extract text into a new storage object
    #print(newpdfText)
    pdf1PageText.append(newpdf1PageText) # Append the list of page texts with the text on each page
pdf1FullText = ' \n '.join(pdf1PageText) # join the texts into one long string
print(pdf1FullText) # Print text
## PDF 2: Email and Phone Directory 
pdfFile2 = open('files/26645.pdf', 'rb') # Open the PDF file from the local folder in pdfFile
pdfReader2 = PyPDF2.PdfFileReader(pdfFile2) # Store the PDF reader object in pdfReader
print(pdfReader2.getNumPages()) # Print number of pages
pdf2PageText = [] # Create empty list object to store text
for page in range(0, pdfReader2.getNumPages()): # Loop through all PDF Pages
    newpdf2PageText = pdfReader2.getPage(page).extractText() # Extract text into a new storage object
    #print(newpdfText)
    pdf2PageText.append(newpdf2PageText) # Append the list of page texts with the text on each page
pdf2FullText = ' \n '.join(pdf2PageText) # join the texts into one long string
print(pdf2FullText) # Print text
### Combine PDFs
pdfFullText = pdf1FullText + pdf2FullText # concatenate text
Explanation: Text Importer
You can use pyperclip to copy and paste text to and from the clipboard, but this implementation will use PyPDF2 to deal with files in a local folder. 
All the files used in these exercises are available here, and are stored in this repository in the local files folder.
End of explanation
## Extract Match Object Lists
extractedPhone = phoneRegex.findall(pdfFullText)
extractedEmail = emailRegex.findall(pdfFullText)
## Loop through Match Objects and pull out the first gorups
allPhoneNumbers = []
for phoneNumber in extractedPhone:
        allPhoneNumbers.append(phoneNumber[0]) # Store zeroeth string from the nth tuples (whole number) in list
#print(extractedEmail)        
allEmails = []
for Email in extractedEmail:
        allEmails.append(Email) # Store every email in list; don't need index because no tuples (no subgroups)
## Print Matching Strings
#print(allPhoneNumbers)
#print(allEmails)
Explanation: Regex Extractions
End of explanation
## Format Results
results = '\n'.join(allPhoneNumbers) + '\n' + '\n'.join(allEmails) 
#Join every phone number into a string, seperated by a new line, create a new line, then join every email into a string, seperated by a new line, and print out the whole thing
print(results)
Explanation: Format and Print Results
End of explanation
<END_TASK>