diff --git a/src/utils/contacts/check_email_existence.py b/src/utils/contacts/check_email_existence.py index bd0b82a..f742f08 100755 --- a/src/utils/contacts/check_email_existence.py +++ b/src/utils/contacts/check_email_existence.py @@ -1,13 +1,14 @@ +import glob import os from pathlib import Path from src.db.mongo_manager import MONGO_STORE_MANAGER from src.utils.excel_reader import read_contacts + # 检查联系人表的有邮件有没有在数据库中 -if __name__ == '__main__': - contacts = read_contacts(str(Path.home()) + "/Desktop/30_05_to_test.xlsx") - mail_list = MONGO_STORE_MANAGER.get_destination_emails() +def check_email_existence(file_path, mail_list): + contacts = read_contacts(file_path) print("mail_list size is " + str(len(mail_list))) mail_raw_list = [] for mail_address in mail_list: @@ -17,3 +18,15 @@ if __name__ == '__main__': if contact.mail not in mail_raw_list: if "gmail" not in 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)