Jan-12-2020, 12:14 PM
(Jan-11-2020, 11:47 PM)Gribouillis Wrote: Try this perhaps
import re s = "Text,10,0.0Text,9,8.0Text,5.45,2.3" new = re.sub(r'(?<=[0-9])(?=[A-Z])', '\n', s) print(new)Finally, learn regexes!
Output:Text,10,0.0 Text,9,8.0 Text,5.45,2.3
Thanks, I actually managed to find my own workaround which was to separate the string into a nested list which each line being its own list. I was then able to write it into the csv line by line using a for loop. Probably not the best way so I will try implement your suggestions. :)