How to save csv files if there are commas in the values

Viewed 26

I have data of type (1234,1234,qwerty,[qwerty,qwerty]) but the last one in square brackets is one value and if I save it

import csv

with open('Z:/eggs.csv', 'w', encoding='utf-8',newline='') as csvfile:
    spamwriter = csv.writer(csvfile, delimiter=',', lineterminator='\r')
    spamwriter.writerow(['1235', '1524', 'qwerty', 'qwerty,qwerty'])

then when I open .csv it outputs like this

1235,1524,qwerty,'qwerty,qwerty'

How can I do it like this:

1235,1524,qwerty,,,qwerty,qwerty

so I can reformat it back

what code do I need to write so that I can write csv in the format above

0 Answers
Related