Буду очень благодарен!
код
import csv
with open('nomer_email.csv', mode = 'w', newline = "") as csv_file:
nomers = ['8 888 888 8888', '9 999 999 9999']
emails = ['[email protected]', '[email protected]']
dict_nomer_emails = {
"list_nomers": nomers,
"list_emails": emails
}
fieldnames = ["phone_numbers", "emails"]
writer = csv.DictWriter(csv_file, fieldnames = fieldnames, delimiter = "\t")
writer.writeheader()
for key, values in dict_nomer_emails.items():
if key == "list_nomers":
for value in values:
writer.writerow({"phone_numbers": value})
if key == "list_emails":
for value in values:
writer.writerow({"emails": value})
Pandas
, всё будет гораздо проще типаdf = pd.DataFrame('list_nomers': nomers, 'list_emails': emails)
и записать в файл будет очень просто.