<su...@aol.com> wrote in message news:d08.50baad3e.36f80...@aol.com...
I've been using re.sub() to try and take the below pattern1 and convert it to
pattern2 (which are below) below that is mycode1. Does anyone have any
suggestions as to how I can figure this out?

pattern1
NTR+A0001 0.01
GLU-A0003 8.21
GLU-A0008 3.619
ARG+A0010 14

[snip lots of data]

pattern2
pKaRes NTR 1 A,value=  0.01
pKaRes GLU 3 A,value= 8.21
pKaRes GLU 8 A,value= 3.619
pKaRes ARG 10 A,value= 14

Since everything appears to be in a fixed column, given a single line from above, this will convert it (no re required):

print 'pKaRes %s %d %s,value= %s' % (line[:3],int(line[5:9]),line[4],line[10:])

-Mark


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to