I am trying to write a function that takes in a list of strings and writes each String in the list as a separate row in a csv file, but I am not getting any output. Could yo
You can use delimiter='\n' with csv.writer.writerow (notice, not writerows). In addition, newline='' is not required as an argument to open.
import sys
import os
import csv
L = ['name1@domain.com', 'name2@domain.com', 'name3@domain.com']
def write_to_csv(list_of_emails):
with open('emails.csv', 'w') as csvfile:
writer = csv.writer(csvfile, delimiter='\n')
writer.writerow(list_of_emails)
write_to_csv(L)