[Tutor] Terminating "\M" characters with regard to csv.DictWriter

David bouncingcats at gmail.com
Sun Aug 8 23:18:25 EDT 2021


On Mon, 9 Aug 2021 at 12:58, boB Stepp <robertvstepp at gmail.com> wrote:
> On 21/08/08 07:05PM, Alex Kleider wrote:

> >All works as I would like except that the newly generated csv file has a
> >'\M' at the end of each line.  I only became aware of this when doing a

It would help us to answer you if you would explain exactly what method
you are using that shows you this '\M'.

> I imagine emacs and vim display things similarly and I know you use Linux.
> Could this be it?

The carriage return character is ASCII decimal 13 which can be generated
by holding the [ctrl] key and pressing the [M] key, sometimes written as
ctrl-M or ^M. Python represents this character as '\r'.

If a file contains this character, run
  cat -A <your_filename>
to display its contents will show this character as '^M',  and line-feed
character ASCII decimal 10 will be shown as '$' at the end of the line.

To see a hex representation of the characters in a file, run
  od -A x -t x1z <your_filename>


More information about the Tutor mailing list