check mail existence with folder
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
|
import glob
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from src.db.mongo_manager import MONGO_STORE_MANAGER
|
from src.db.mongo_manager import MONGO_STORE_MANAGER
|
||||||
from src.utils.excel_reader import read_contacts
|
from src.utils.excel_reader import read_contacts
|
||||||
|
|
||||||
|
|
||||||
# 检查联系人表的有邮件有没有在数据库中
|
# 检查联系人表的有邮件有没有在数据库中
|
||||||
if __name__ == '__main__':
|
def check_email_existence(file_path, mail_list):
|
||||||
contacts = read_contacts(str(Path.home()) + "/Desktop/30_05_to_test.xlsx")
|
contacts = read_contacts(file_path)
|
||||||
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
|
||||||
print("mail_list size is " + str(len(mail_list)))
|
print("mail_list size is " + str(len(mail_list)))
|
||||||
mail_raw_list = []
|
mail_raw_list = []
|
||||||
for mail_address in mail_list:
|
for mail_address in mail_list:
|
||||||
@@ -17,3 +18,15 @@ if __name__ == '__main__':
|
|||||||
if contact.mail not in mail_raw_list:
|
if contact.mail not in mail_raw_list:
|
||||||
if "gmail" not in contact.mail:
|
if "gmail" not in contact.mail:
|
||||||
print(contact.mail)
|
print(contact.mail)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
||||||
|
_folder_path = "/Users/panlei/Desktop/to_check"
|
||||||
|
# get files of a folder
|
||||||
|
for file in os.listdir(_folder_path):
|
||||||
|
if file.endswith(".xlsx"):
|
||||||
|
_file_path = os.path.join(_folder_path, file)
|
||||||
|
# print(_file_path)
|
||||||
|
print("Will check file " + _file_path)
|
||||||
|
check_email_existence(_file_path, mail_list)
|
||||||
|
|||||||
Reference in New Issue
Block a user