Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def email_gen(list_of_names):
- '''
- Функция принимает список списков [['Имя_1', 'Фамилия_1'], ..., ['Имя_N', 'Фамилия_N']]
- Создается пустой список emails, который в ходе выполнения, заполнится почтовыми адресами.
- Идет проверка на совпадение создоваемого адреса с существующими.
- Если имена и фамилии сотрудников совпадают, к первой букве имени добавляется вторая и т.д.
- Заносит полученный адресс в список emails и возваращает его.
- '''
- emails = []
- letter = 1
- for i in list_of_names:
- if i[1] + '.' + i[0][0:letter] + '@company.io' in emails:
- letter += 1
- emails.append(i[1] + '.' + i[0][0:letter] + '@company.io')
- return emails
- task_file = open('task_file.txt', 'r')
- text = task_file.read().split('\n')
- task_file.close()
- text_person = []
- [text_person.append(n.split(', ')) for n in text]
- first_last_name = []
- for j in range(1, len(text_person) - 1):
- first_last_name.append((text_person[j][1] + '/' + text_person[j][2]).split('/'))
- email = email_gen(first_last_name)
- task_file_valid = open('task_file_valid.txt', 'w')
- task_file_invalid = open('task_file_invalid.txt', 'w')
- task_file_valid.write(text[0] + '\n')
- task_file_invalid.write(text[0] + '\n')
- for j in range(1, len(text) - 1):
- if len(text_person[j][1]) != 0 \
- and text_person[j][1].isalpha() \
- and 'wf' not in text_person[j][1] \
- and len(text_person[j][2]) != 0 \
- and text_person[j][2].isalpha() \
- and 'wf' not in text_person[j][2] \
- and text_person[j][1] != text_person[j][2] \
- and len(text_person[j][3]) == 7 \
- and text_person[j][3].isdigit() \
- and int(text_person[j][3]) != 0 \
- and len(text_person[j][4]) != 0:
- task_file_valid.write(email[j-1] + text[j] + '\n')
- else:
- task_file_invalid.write(text[j] + '\n')
- task_file_valid.close()
- task_file_invalid.close()
Advertisement
Add Comment
Please, Sign In to add comment