newbie problem

Matt Gerrans matt_gerrans at
Tue Aug 27 20:10:14 CEST 2002

How's this (I saved your sample input to a file called c:\temp\input.dat,

for line in open( r'c:\temp\input.dat' ).readlines():
   len(line.split()) > 2:
      if line.split()[0]=='#':
         print '|'.join([tag]+line.split())

(This is quick 'n' dirty, of course, if I was *really* going to use it,
there would be a bit of error handling and it wouldn't be using hard-coded
filenames, etc., but it is good enough for one-shot use, if you are just
using it yourself (I think -- you can see how badly it falls apart on your
real data file!).)

"Manuel Hendel" <manuel at> wrote in message
news:mailman.1030451855.5998.python-list at
> On Tue, Aug 27, 2002 at 08:06:43AM -0400, Peter Hansen wrote:
> >
> > Do you want the experience of figuring most of this out yourself, so
> > we should provide hints, or do you want a ready-made solution which
> > gets the job done, and from which you can learn for next time?
> >
> > This is only about a ten or fifteen line program, if that, I think,
> > so it's probably pretty easy for us to post a full working version
> > if you wish.
>  To be honest, I would prefer the one from which I could learn for
>  next time? :-)
>  During the time I wrote my mail and waited for an answer, I tried to
>  get this started, I'm getting more and more confused. I would be very
>  happy if you can provide me with this program.
>  Thank you very much in advance,
>     Manuel
> --
> Calling you stupid is an insult to stupid people!
> -Wanda, "A Fish Called Wanda"

More information about the Python-list mailing list