[EMAIL PROTECTED] wrote:
> hi.
> I have a file with this kind of structure:
> 
> Hxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> .........
> .....
> .....
> xxxxx
> Hxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> ...
> ....
> ...
> xxxxx
> Hxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> .....
> ....
> and so on....lines starting with 'H' are headers. I wish to get the
> parts of the file
> where line start with 'H' all the way till before the next 'H' and save
> to files of different names...how is the best way to do it ?
> thanks

Something like this?

out = None
for line in open(...):
   if line.startswith('H'):
     if out:
       out.close()
     out = open(..., 'w')
   if out:
     out.write(line)
out.close()

Kent
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to