Newbie array question

Neale nhirsh2 at ieee.org
Mon Jun 14 10:22:10 EDT 2004


danb_83 at yahoo.com (Dan Bishop) wrote in message news:<ad052e5c.0406121517.4a3bd684 at posting.google.com>...
> nhirsh2 at ieee.org (Neale) wrote in message news:<2d7af4f8.0406112032.4cb4438a at posting.google.com>...
> > My first task with Python is to scan multiple small text files and
> > "batch together" those records with a "5" or "6" in column 2, and then
> > save as a new file. The records are 256 characters. I know it sounds
> > like a homework problem, but it's not.
> 
> Assuming that all your records are strings in an array called
> "records", you can discard the ones without a '5' or '6' in column 2
> (column 1 in 0-based indexing) with:
> 
>    records = [r for r in records if r[1] in ('5', '6')]
Thank you all for such high quality help. And fast, too!



More information about the Python-list mailing list