Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re, openpyxl, os, sys
- def open_xl_file():
- loc = input("Please enter path of the file:")
- os.chdir(loc)
- file = input("Filename:")
- return openpyxl.load_workbook(file, use_iterators=True)
- def sheet_select():
- wb = open_xl_file()
- sheet = input("Which Sheet do you want to email?\n")
- wb.get_sheet_by_name('Maharashtra')
- def sort_email_from_xl():
- sheet = sheet_select()
- return sheet
- ## emailRegex = re.compile(r'''([a-zA-Z0-9._%+-]+@+[a-zA-Z0-9.-]+(\.[a-zA-Z]{2,4}))''',re.VERBOSE)
- emailRegex = re.compile(".*?([a-zA-Z0-9\._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,4}).*?")
- customeremails = []
- for row in sheet.iter_rows():
- if emailRegex.match(cell.text):
- mail = emailRegex.match(cell.text).group[0]
- cell.text = mail
- customeremails.append(mail)
- print(customeremails)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement