file reading by record separator (not line by line)

Tijs tijs_news at bluescraper.com
Thu May 31 09:15:02 EDT 2007


aspineux wrote:

> 
> something like
> 
> name=None
> lines=[]
> for line in open('yourfilename.txt'):
>     if line.startwith('>'):
>         if name!=None:
>             print 'Here is the record', name
>             print lines
>             print
>         name=line.stripr('\r')
>         lines=[]
>     else:
>         lines.append(line.stripr('\n'))
> 

That would miss the last chunk.

-- 

Regards,
Tijs



More information about the Python-list mailing list