Re: file reading by record separator (not line by line)
- From: aspineux <aspineux@xxxxxxxxx>
- Date: 31 May 2007 05:58:22 -0700
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
name=line.stripr('\r')
lines=[]
else:
lines.append(line.stripr('\n'))
On 31 mai, 14:39, Lee Sander <lesa...@xxxxxxxxx> wrote:
I wanted to also say that this file is really huge, so I cannot
just do a read() and then split on ">" to get a record
thanks
lee
On May 31, 1:26 pm, Lee Sander <lesa...@xxxxxxxxx> wrote:
Dear all,
I would like toreada really hugefilethat looks like this:
name1....
line_11
line_12
line_13
...>name2 ...
line_21
line_22
...
etc
where line_ij is just a free form text on that line.
how can ireadfileso that every time i do a "read()" i get exactly
onerecord
up to the next ">"
many thanks
Lee
.
- Follow-Ups:
- References:
- file reading by record separator (not line by line)
- From: Lee Sander
- Re: file reading by record separator (not line by line)
- From: Lee Sander
- file reading by record separator (not line by line)
- Prev by Date: Re: with ctypes, how to parse a multi-string
- Next by Date: Re: PEP 8 style enforcing program
- Previous by thread: Re: file reading by record separator (not line by line)
- Next by thread: Re: file reading by record separator (not line by line)
- Index(es):
Relevant Pages
|