[Tutor] Expanding a Python script to include a zcat and awk pre-process

Kent Johnson kent37 at tds.net
Fri Jan 8 15:20:47 CET 2010


On Fri, Jan 8, 2010 at 2:24 AM,  <galaxywatcher at gmail.com> wrote:

> So how do I
> uncompress zip and gzipped files in Python,

zipfile and gzip

> and how do I force split to only
> evaluate the first two columns?

Use the optional second argument to split():
line.split(',', 2)

> Better yet, can I tell split to not evaluate
> commas in the double quoted 3rd column?

Use the csv module.

Kent


More information about the Tutor mailing list