On 12/02/2020 08:15, allu.matikainen@hotmail.com wrote:
Hi, I would like if the DictWriter would be able to write escape characters (\n and \r and their combinations such as \n\n\n and \r\n) as literal characters. At the moment, DictWriter writes \n:s as new lines (shown in notepad or Excel) and I would like it to just write "\n" characters in my csv file.
I asked a question about this on Stack Overflow but have had no good answers yet. My question also has an example of the data and its form. https://stackoverflow.com/questions/60073809/python-how-to-write-literal-n-a...
I think my advice would be a variation on "Don't do that!" If you can massage your data into the right format before you try writing it, that would be preferable to having DictWriter mangle your strings in what is essentially an arbitrary way. -- Rhodri James *-* Kynesim Ltd