Newbie help with manipulating text files

Laura Creighton lac at cd.chalmers.se
Sat May 26 05:50:06 EDT 2001


Hi jk.

1. Do you know that the mail you are sending out appears to come as
From: "jk" <user at host.com>?  Do you want this?

2. Every solution I have seen so far assumes that whatever you are
matching as the middle can _only_ arrive as the first parts of
middles.  Is this true?  Or can you get things like this?
--------
junk header junk junk junk junk
header junk header junk header junk
header junk and just to be nasty I will start the next line with
middle because I am a real stinker and then more header junk
header junk header junk

middle middle middle
middle middle middle
middle middle middle

footer junk footer junk footer junk
footer footer why not be a stinker here as well and put
middle footer junk junk footer

-----------
if this is the case then `what is a middle' needs to be better
specified.  In my data you could just read header until you
get a blank line, then read middle, and then read until the next
blank line.  This is undoubtably useless for you (otherwise you
could just have skipped the matching part altogether)  and will fail
if you get blank lines in your message which are not used as
separators.  

By the way if somebody sends you:
------------
header header header

middle middle
middle middle

middle middle
middle middle

footer footer
-------------
do you need to preserve the blank line in the middle of the middles?
the separating blank lines?

So maybe you can say that a middle is a real middle only if it has a
following real middle, or if it follows a real middle.  this makes
-----
header header
middle
footer
-----
fail if that is your whole message and not a stinker header made by me.
so you will have to treat this special.

The only reason I mention this is that programs that rely on the other
guy providing perfectly conforming data are only any good when you are
the other guy (and not always then, alas).  All others make mistakes and 
flaunt existing standards most indecently.

good luck,
Laura Creighton




More information about the Python-list mailing list