[Tutor] Parsing large files

Greg Gent GGent at healthcare-automation.com
Fri Feb 6 14:08:44 EST 2004


RTFQ.

The OP actaully stated that he was using a subset of columns into each of
the two resulting files.  Each resulting file would have the same number of
rows as the original, not of each other (which since it was stated MORE THAN
1000 rows...your suggestion of 500 wouldn't accomplish same number of rows
in each file either).

As already stated the csv module seems appropriate.

BTW,

The unix split command will not simplify this task.  It may split the file
into N 500 line pieces (if you tell it to use -l 500).  However, that is not
what was asked.


> -----Original Message-----
> From: Rick Pasotto [mailto:rick at niof.net]
> Sent: Friday, February 06, 2004 1:46 PM
> To: tutor at python.org
> Subject: Re: [Tutor] Parsing large files
> 
> 
> On Fri, Feb 06, 2004 at 12:33:10PM -0500, Andrew Eidson wrote:
> > I have a text file that is tab delimited.. it has 321 columns with
> > over 1000 rows.. I need to parse this out to 2 text files 
> with roughly
> > half the columns and the same number of rows. Just looking on some
> > guidance on the best way of doing this (been working on a 
> GUI so much
> > lately my brain is toast)
> 
> Why does it matter how many columns there are? Are you 
> rearranging them
> or using a subset? If not just write the first 500 lines to 
> one file and
> then the rest to another. The unix 'split' command will do this.
> 
> Don't make things more complicated than necessary.
> 
> -- 
> "All progress is based upon the universal innate desire
>  on the part of every organism to live beyond its income."
> 		-- Samuel Butler  *KH*
>     Rick Pasotto    rick at niof.net    http://www.niof.net
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 



More information about the Tutor mailing list