Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65545
| Date | 2014-02-06 11:51 -0600 |
|---|---|
| From | Tim Chase <python.list@tim.thechases.com> |
| Subject | Re: parse a csv file into a text file |
| References | <5c268845-003f-4e24-b27a-c89e9fbfcc6c@googlegroups.com> <ld04ln$6h0$2@ger.gmane.org> <ld0he1$dfb$1@ger.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6449.1391709038.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
parse a csv file into a text file Zhen Zhang <zhen.zhang.uoft@gmail.com> - 2014-02-05 16:10 -0800
Re: parse a csv file into a text file Asaf Las <roegltd@gmail.com> - 2014-02-05 16:17 -0800
Re: parse a csv file into a text file Zhen Zhang <zhen.zhang.uoft@gmail.com> - 2014-02-05 23:56 -0800
Re: parse a csv file into a text file Roy Smith <roy@panix.com> - 2014-02-05 19:33 -0500
Re: parse a csv file into a text file Zhen Zhang <zhen.zhang.uoft@gmail.com> - 2014-02-05 23:52 -0800
Re: parse a csv file into a text file Asaf Las <roegltd@gmail.com> - 2014-02-06 00:15 -0800
Re: parse a csv file into a text file Asaf Las <roegltd@gmail.com> - 2014-02-06 00:48 -0800
Re: parse a csv file into a text file MRAB <python@mrabarnett.plus.com> - 2014-02-06 13:16 +0000
Re: parse a csv file into a text file Rustom Mody <rustompmody@gmail.com> - 2014-02-06 05:20 -0800
Re: parse a csv file into a text file MRAB <python@mrabarnett.plus.com> - 2014-02-06 00:34 +0000
Re: parse a csv file into a text file Zhen Zhang <zhen.zhang.uoft@gmail.com> - 2014-02-06 00:01 -0800
Re: parse a csv file into a text file Tim Chase <python.list@tim.thechases.com> - 2014-02-05 18:46 -0600
Re: parse a csv file into a text file Asaf Las <roegltd@gmail.com> - 2014-02-05 19:59 -0800
Re: parse a csv file into a text file Tim Chase <python.list@tim.thechases.com> - 2014-02-05 22:09 -0600
Re: parse a csv file into a text file Asaf Las <roegltd@gmail.com> - 2014-02-05 20:17 -0800
Re: parse a csv file into a text file Zhen Zhang <zhen.zhang.uoft@gmail.com> - 2014-02-06 00:07 -0800
Re: parse a csv file into a text file Tim Chase <python.list@tim.thechases.com> - 2014-02-06 12:49 -0600
Re: parse a csv file into a text file Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-06 00:50 +0000
Re:parse a csv file into a text file Dave Angel <davea@davea.name> - 2014-02-05 19:57 -0500
Re: parse a csv file into a text file Zhen Zhang <zhen.zhang.uoft@gmail.com> - 2014-02-06 00:12 -0800
Re: parse a csv file into a text file Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-02-06 10:49 +0200
Re: parse a csv file into a text file Dave Angel <davea@davea.name> - 2014-02-06 06:35 -0500
Re: parse a csv file into a text file Dave Angel <davea@davea.name> - 2014-02-06 06:53 -0500
Re: parse a csv file into a text file Terry Reedy <tjreedy@udel.edu> - 2014-02-05 22:01 -0500
Re: parse a csv file into a text file Neil Cerutti <neilc@norwich.edu> - 2014-02-06 14:02 +0000
Re: parse a csv file into a text file Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-06 17:40 +0000
Re: parse a csv file into a text file Tim Chase <python.list@tim.thechases.com> - 2014-02-06 11:51 -0600
Re: parse a csv file into a text file Tim Golden <mail@timgolden.me.uk> - 2014-02-06 18:05 +0000
Re: parse a csv file into a text file Neil Cerutti <neilc@norwich.edu> - 2014-02-06 18:34 +0000
Re: parse a csv file into a text file Tim Chase <python.list@tim.thechases.com> - 2014-02-06 12:51 -0600
csiph-web