En Mon, 26 Jan 2009 13:35:39 -0200, J. Cliff Dyer <j...@sdf.lonestar.org> escribió:
On Sun, 2009-01-25 at 18:23 -0800, John Machin wrote:
On Jan 26, 1:03 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:
> En Sun, 25 Jan 2009 23:30:33 -0200, Tim Chase
> <python.l...@tim.thechases.com> escribió:

> > I suppose if I were really smart, I'd dig a little deeper in the CSV
> > module to sniff out the "right" way to parse tab-delimited files.
>
> It's so easy that don't doing that is just inexcusable lazyness :)
> Your own example, written using the csv module:
>
> import csv
>
> f = csv.reader(open('customer_x.txt','rb'), delimiter='\t')
> headers = f.next()
> for line in f:
>      field1, field2, field3 = line
>      do_stuff()
>

And where in all of that do you recommend that .decode(some_encoding)
be inserted?

If encoding is an issue for your application, then I'd recommend you use
codecs.open('customer_x.txt', 'rb', encoding='ebcdic') instead of open()

This would be the best way *if* the csv module could handle Unicode input, but unfortunately this is not the case. See my other reply.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to