csv module and NULL data byte
Neil Cerutti
neilc at norwich.edu
Thu Mar 1 08:57:08 EST 2018
On 2018-03-01, Tim Chase <python.list at tim.thechases.com> wrote:
> On 2018-02-28 21:38, Dennis Lee Bieber wrote:
>> > with open( fname, 'rt', encoding='iso-8859-1' ) as csvfile:
>>
>> Pardon? Has the CSV module changed in the last year or so?
>>
>> Last time I read the documentation, it was recommended that
>> the file be opened in BINARY mode ("rb").
>
> It recommends binary mode, but seems to largely work fine with
> text/ascii mode or even arbitrary iterables. I've not seen the
> rationale behind the binary recommendation, but in 10+ years of using
> the csv module, I've not found any issues in using text/ascii mode
> that were solved by switching to using binary mode.
Binary mode was recommended for Python 2, but not 3, where you
open in text mode but use newline=''.
--
Neil Cerutti
More information about the Python-list
mailing list