I am working on a small project,where one of the step is to write on a csv file a list of data. I am looping through a list,and fetching specific data and writing it to a csv. The problem is when the write operation is being processed it removes previous entries of the csv file.My csv writing method is as follows: and an example
def csv_writer(data_list,file_path):
import csv
file_p = open(file_path, "wb")
write_pattern = csv.writer(file_p, delimiter=",", quotechar=",")
write_pattern.writerow(data_list)
file_p.close()
An example data list is:
data_list = ['a', '', 'a', 'a', 'd', 'e']
And I am trying to have data in the file as follows:
a,,a,d,e
a,b,c,d,e
a,g.j,l,m
Thanks in advance.