rm duplicated items while generating contact list
This commit is contained in:
@@ -8,7 +8,7 @@ from src.utils.excel_reader import read_contacts, fr_phone_number_prefix, get_ra
|
|||||||
|
|
||||||
|
|
||||||
def upload_contacts_list():
|
def upload_contacts_list():
|
||||||
_contacts_to_book = read_contacts("/Users/lpan/Desktop/contact_list_2024-04-15.xlsx")
|
_contacts_to_book = read_contacts("/Users/lpan/Desktop/contact_list_2024-04-18.xlsx")
|
||||||
return _contacts_to_book
|
return _contacts_to_book
|
||||||
|
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ def fix_phone_number_format(file_path):
|
|||||||
if _contact.phone[0:2] not in fr_phone_number_prefix:
|
if _contact.phone[0:2] not in fr_phone_number_prefix:
|
||||||
print(_contact)
|
print(_contact)
|
||||||
_contact.phone = get_random_fr_phone_numbers()
|
_contact.phone = get_random_fr_phone_numbers()
|
||||||
write_new_contacts_to_excel(_contact_list, file_name="09_04_to_test")
|
write_new_contacts_to_excel(_contact_list, file_name="22_04_to_test")
|
||||||
|
|
||||||
|
|
||||||
def write_new_contacts_to_excel(valid_contacts: list, file_name=str(datetime.date.today())):
|
def write_new_contacts_to_excel(valid_contacts: list, file_name=str(datetime.date.today())):
|
||||||
@@ -46,7 +46,7 @@ def write_new_contacts_to_excel(valid_contacts: list, file_name=str(datetime.dat
|
|||||||
workbook.close()
|
workbook.close()
|
||||||
|
|
||||||
|
|
||||||
def generate_valid_contact_list_for_day(sement_number = 1):
|
def generate_valid_contact_list_for_day(sement_number=1):
|
||||||
_valid_contact_list = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
_valid_contact_list = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||||
_all_contacts = MONGO_STORE_MANAGER.get_all_contacts_to_book()
|
_all_contacts = MONGO_STORE_MANAGER.get_all_contacts_to_book()
|
||||||
_contact_to_save = []
|
_contact_to_save = []
|
||||||
@@ -63,14 +63,29 @@ def generate_valid_contact_list_for_day(sement_number = 1):
|
|||||||
|
|
||||||
if _contact.url_validated:
|
if _contact.url_validated:
|
||||||
if _contact.last_name is not None and len(_contact.last_name) > 0:
|
if _contact.last_name is not None and len(_contact.last_name) > 0:
|
||||||
|
_need_to_save = True
|
||||||
|
# remove the duplicated items
|
||||||
|
for _added_item in _contact_to_save:
|
||||||
|
if (_added_item.mail == _contact.mail
|
||||||
|
and _added_item.phone == _contact.phone
|
||||||
|
and _added_item.passport == _contact.passport
|
||||||
|
and _added_item.last_name == _contact.last_name
|
||||||
|
and _added_item.first_name == _contact.first_name):
|
||||||
|
_need_to_save = False
|
||||||
|
if _need_to_save:
|
||||||
_contact_to_save.append(_contact)
|
_contact_to_save.append(_contact)
|
||||||
write_new_contacts_to_excel(_contact_to_save)
|
|
||||||
for i in range(0, sement_number):
|
|
||||||
_step = int(len(_contact_to_save) / sement_number)
|
|
||||||
_sublist = _contact_to_save[i * _step:_step * (i + 1)]
|
|
||||||
_file_name = str(datetime.date.today()) +"_"+ str(i+1)
|
|
||||||
write_new_contacts_to_excel(_sublist,file_name=_file_name)
|
|
||||||
|
|
||||||
|
# if _contact.mail == "talasapdne@gmx.de":
|
||||||
|
# print(_contact.__hash__())
|
||||||
|
# if _contact not in _contact_to_save:
|
||||||
|
# _contact_to_save.add(_contact)
|
||||||
|
_contact_to_save_list = _contact_to_save
|
||||||
|
write_new_contacts_to_excel(_contact_to_save_list)
|
||||||
|
for i in range(0, sement_number):
|
||||||
|
_step = int(len(_contact_to_save_list) / sement_number)
|
||||||
|
_sublist = _contact_to_save_list[i * _step:_step * (i + 1)]
|
||||||
|
_file_name = str(datetime.date.today()) + "_" + str(i + 1)
|
||||||
|
write_new_contacts_to_excel(_sublist, file_name=_file_name)
|
||||||
|
|
||||||
|
|
||||||
def merge_contact_list_files(file_list: list, final_file_name="merged_contact_list"):
|
def merge_contact_list_files(file_list: list, final_file_name="merged_contact_list"):
|
||||||
@@ -97,11 +112,14 @@ def generate_all_contact_list():
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# contacts_to_book = upload_contacts_list()
|
# contacts_to_book = upload_contacts_list()
|
||||||
# MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book)
|
# MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book)
|
||||||
generate_valid_contact_list_for_day(sement_number=3)
|
generate_valid_contact_list_for_day(sement_number=2)
|
||||||
# generate_all_contact_list()
|
# generate_all_contact_list()
|
||||||
# merge_contact_list_files(
|
# merge_contact_list_files(
|
||||||
# ["/Users/lpan/Desktop/contact_list_2024-04-10.xlsx",
|
# ["/Users/lpan/Desktop/20_04_to_test_1.xlsx",
|
||||||
# "/Users/lpan/Desktop/contact_list_2024-04-09.xlsx",
|
# "/Users/lpan/Desktop/19_04_to_test.xlsx",
|
||||||
# "/Users/lpan/Desktop/contact_list_2024-04-06.xlsx",
|
# "/Users/lpan/Desktop/17_18_04_to_test.xlsx",
|
||||||
# "/Users/lpan/Desktop/contact_list_2024-04-04.xlsx"])
|
# "/Users/lpan/Desktop/09_04_to_test.xlsx",
|
||||||
# fix_phone_number_format("/Users/lpan/Desktop/09_04_to_test.xlsx")
|
# "/Users/lpan/Desktop/31_03_to_test.xlsx",
|
||||||
|
# "/Users/lpan/Desktop/12_04_to_test.xlsx",
|
||||||
|
# "/Users/lpan/Desktop/16_04_to_test.xlsx"])
|
||||||
|
# fix_phone_number_format("/Users/lpan/Desktop/22_04_to_test.xlsx")
|
||||||
|
|||||||
Reference in New Issue
Block a user