On 12/02/2020 08:15, allu.matikai...@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-and-r-characters-to-a-csv-file-with-dictwriter

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
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/WPQ3EFCD4N7ZO5ZU54WN5W6JK7VM2VTS/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to