simple text file 'parsing' question
Magnus L. Hetland
mlh at idt.ntnu.no
Mon Jun 21 08:29:24 EDT 1999
Matt Gushee <mgushee at havenrock.com> writes:
> KP <terocr at mysolution.com> writes:
>
> > Here's my dilema: a directory filled (200+) with small emails. My goal
> > is to strip all the headers and combine them into one file. I can read
> > all the files just fine and write them all to one file, but I cannot
> > discern how to strip the headers.
Just remove everything up to and including the first blank line. That
represents the end of the header. For instance:
file = open(resultFileName,'w')
# ...
lines = open(name).readlines()
lines = lines[lines.index("")+1:]
file.writelines(lines)
# ...
file.close()
--
Magnus Making no sound / Yet smouldering with passion
Lie The firefly is still sadder / Than the moaning insect
Hetland : Minamoto Shigeyuki
More information about the Python-list
mailing list