How can I write to a csv file in python to a list (which is a list of lists)
[['CL07001006', 'IM20010809'], ['IM75630511', 'IM75550511', 'IM75610511', 'IM75640511', 'IM75500511'],['CL0700100r','CL0700100U','PL07001006']]
in the following format:
CL07001006 IM75630511 CL0700100r IM20010809 IM75550511 CL0700100U IM75610511 PL07001006 IM75640511 IM75500511
I tried something like below:
def demo(): lol = [['CL07001006', 'IM20010809'], ['IM75630511', 'IM75550511', 'IM75610511', 'IM75640511', 'IM75500511']] file = open("dummy.csv", 'wb') fileWritter = csv.writer(file, delimiter='\n',quotechar='|', quoting=csv.QUOTE_MINIMAL) for l in lol: fileWritter.writerow(l) if __name__ == '__main__': demo()
which is as follows:
CL07001006 IM20010809 IM75630511 IM75610511 IM75640511 IM75500511
Thanks.
user1289853
source share