write csv file with double quotes for particular column not working

前端 未结 3 1460
执念已碎
执念已碎 2021-01-11 16:43

I\'m trying to write a csv file using python csv writer.

In which one of the column value is enclosed in \"\" [double quotes] e.g. : \'col1\' \'col2\' \"test\", when

3条回答
  •  春和景丽
    2021-01-11 17:19

    As far as I can tell from the accepted answer from @GiovanniPi, is that the default is

    quotechar= '"'
    

    Because the expected output already has double quotes, this has to be changed to:

    quotechar = "'"
    

    I am not sure what you would do if you needed to have both single and double quotes as quotechar requires a 1-character string

提交回复
热议问题