Python Сортировщик баз по типу.

Starkark

Заблокирован
Сообщения
0
Симпатии
0
Баллы
0
Сортирует базу на номера(несколько стран) ,mail,other,trash and etc.
Версия 3+
Python:
file = open(r"D:\Исходная база.txt",'r',errors="ignore")

def phone(spliiter):
phone_1 = spliiter[0].isdigit()
if phone_1 == True:
phone = spliiter[0]
phone_2_ru = spliiter[0].startswith("9")
phone_3_ru = spliiter[0].startswith("8")
phone_4_ru = spliiter[0].startswith("7")
if (phone_3_ru == True or phone_4_ru == True) and (len(phone) == 12 or len(phone) == 11):
file_phone_RU = open("PHONE[RUS].txt",'a')
file_phone_RU.write(phone_plus_replase)
elif len(phone) == 10 and (spliiter[0].startswith("3") == True or spliiter[0].startswith("4") == True):
phonre_number_edit = "7" + str(phone_plus_replase)
file_phone_RU = open("PHONE[NEW].txt", 'a')
file_phone_RU.write(phonre_number_edit)
elif phone_2_ru == True:
phonre_number_edit = "7" + str(phone_plus_replase)
file_phone_RU = open("PHONE[RUS].txt", 'a')
file_phone_RU.write(phonre_number_edit)
elif spliiter[0].startswith("375") == True and len(phone) == 12:
file_phone_RU = open("PHONE[BY].txt",'a')
file_phone_RU.write(phone_plus_replase)
elif spliiter[0].startswith("380") == True and len(phone) == 12:
file_phone_RU = open("PHONE[UA].txt",'a')
file_phone_RU.write(phone_plus_replase)
elif spliiter[0].startswith("373") == True and (len(phone) == 12 or len(phone) == 11):
file_phone_RU = open("PHONE[MOLDOVA].txt", 'a')
file_phone_RU.write(phone_plus_replase)
elif spliiter[0].startswith("44") == True and len(phone) == 13:
file_phone_RU = open("PHONE[UK].txt", 'a')
file_phone_RU.write(phone_plus_replase)
else:
file_phone_RU = open("PHONE[TRASH].txt", 'a')
file_phone_RU.write(line)
def mail(spliiter):
mail_find_1 = line.find("@")
mail_find_2 = line.find(":")
if mail_find_1 != -1 and mail_find_2 != -1:
file_mail = open("Mails.txt",'a')
file_mail.write(line)



for line in file:
phone_plus_replase = line.replace("+","")
spliiter = phone_plus_replase.split(":")
try:
password = len(spliiter[1])
except IndexError:
file_TRASH = open("TRASH_.txt",'a')
file_TRASH.write(line)
continue
if password >= 6:
if spliiter[0].isdigit() == True:
phone(spliiter)
continue
elif spliiter[0].find("@") != -1:
mail(spliiter)
continue
else:
file_other = open("OTHER_.txt",'a')
file_other.write(line)

else:
continue
file_phone_RU.close()
file_other.close()
file_TRASH.close()
file.close()