csv.Sniffer: wrong detection of the end of line delimiter

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Thu Dec 29 22:50:22 CET 2005

In <mailman.2663.1135825146.18701.python-list at python.org>, Steve Holden

> Laurent Laporte wrote:
>> I'm using cvs standard module under Python 2.3 / 2.4 to read a CSV
>> file. The file is opened in binary mode, so I keep the end of line
>> terminator.
> It's not advisable to open a file like a CSV, intended for use as text, 
> in binary mode.

But the docs "demand" this explicitly and all examples in the docs fulfill
that demand.

>From http://docs.python.org/lib/csv-contents.html :

  If csvfile is a file object, it must be opened with the 'b' flag on
  platforms where that makes a difference.

I guess the reason is the same as for "text" pickle format:  If you don't
use binary mode the file is not platform independend anymore because some
OSes "manipulate" the data in text mode.

	Marc 'BlackJack' Rintsch

More information about the Python-list mailing list