On 2014-02-06 17:40, Mark Lawrence wrote:
> On 06/02/2014 14:02, Neil Cerutti wrote:
> >
> > You must open the file in binary mode, as that is what the csv
> > module expects in Python 2.7. newline handling can be enscrewed
> > if you forget.
> >
> > file = open('raw.csv', 'b')
> >
> 
> I've never opened a file in binary mode to read with the csv module 
> using any Python version.  Where does it state that you must do
> this?

While the docs don't currently say anything about it, all the
examples at [1] use 'rb' or 'wb' when opening the file.  I've long
wondered about that.  Especially as I've passed non-file objects like
lists/iterators to the csv.reader/csv.DictReader and had them work
just fine (and would be a little perturbed if they broke).

-tkc

[1] http://docs.python.org/2/library/csv.html
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to