En Fri, 13 Apr 2007 07:08:05 -0300, Flyzone <[EMAIL PROTECTED]>
escribió:
> A little question: the pat.split can split without delete the date?
No, but instead of reading the whole file and splitting on dates, you
could iterate over the file and detect block endings:
def split_on_dates(ftoparse):
block = None
for line in ftoparse:
if fancy_date_regexp.match(line):
# a new block begins, yield the previous one
if block is not None:
yield current_date, block
current_date = line
block = []
else:
# accumulate lines for current block
block.append(line)
# don't forget the last block
if block is not None:
yield current_date, block
for date, block in split_on_dates(ftoparse):
# process block
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list