[Tutor] simple search and replace...

Spencer Parker inthefridge at gmail.com
Wed Mar 31 17:20:19 CEST 2010

I am writing a script to help me add line breaks at certain segments of HL7
messages.  Not sure if anyone here is familiar with what an HL7 message is
or not.  We receive them out of our database with all the segments on one
line.  I am trying to write a script to allow me to separate them at a
certain point and add a line break.  A message would look like this:


What I want to do is where it says, PID, is add a line break right before
that to knock it down to a new line.

I currently have a dictionary that contains all of the segments and am
wondering what the best way to approach this is.  I thought about a regular
expression...but...I don't think that is the best way.

The basic file i/o I know...it is the search and carriage I need help with.
 Any ideas?

I was thinking of using a 'for i in segments' statement to run through the
dictionary of items.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100331/87b8aebb/attachment.html>

More information about the Tutor mailing list