Mar-24-2021, 11:09 PM
(Mar-24-2021, 11:00 PM)brunolelli Wrote:(Mar-24-2021, 10:55 PM)snippsat Wrote: If i just copy some of your data,then doing some stuff to get it in a list data structure.
You can append to list so get similar structure,then it easy to write to csv.
import csv data = '''\ 23/03/2021 09:09 50 18 34 1 23/03/2021 09:09 50 18 34 1 23/03/2021 09:09 50 19 34 1 23/03/2021 09:09 50 19 34 1''' lst = data .split('\n') lst = [i.split() for i in lst] print(lst) with open("out.csv", "w", newline="") as f: writer = csv.writer(f) writer.writerows(lst)
Output:[['23/03/2021', '09:09', '50', '18', '34', '1'], ['23/03/2021', '09:09', '50', '18', '34', '1'], ['23/03/2021', '09:09', '50', '19', '34', '1'], ['23/03/2021', '09:09', '50', '19', '34', '1']] # out.csv 23/03/2021,09:09,50,18,34,1 23/03/2021,09:09,50,18,34,1 23/03/2021,09:09,50,19,34,1 23/03/2021,09:09,50,19,34,1
Thank you for your assistance, but I don't think it will work...
As you can see, I'm writing my data from this code
fields=[dt_string,company1,company2,company3,company4]And it's already a list...
And I'm basically printing or writing line by line of this list, because purely it's a list with just one line that I'm writing every second basically
I found a way to solve my issu.... Saving as TXT!