Friends,
I wrote a small piece of code (given below). The aim is to take each line
in a file, split the fields, replace the first four fields and then write
the new lines in a output file. The input and output are given in the
attached file. The output contains fields which are irregularly placed
depending up on the size of the field. I am thinking to fix the size of
each field. Kindly provide me some way on how i can do the same or a better
way to fix placement of fields.

with open('tmp') as tp:
    for line in tp:
        line=line.split()
        p1=atm_type[line[0]];p2=atm_type[line[1]]
        p3=atm_type[line[2]];p4=atm_type[line[3]]
        new='\t'.join(line[4:10])
        bond.write('   %s\t%s\t%s\t%s\t%s\n' % (p1,p2,p3,p4,new) )


-- 
C. Balasubramanian

Attachment: test.output
Description: Binary data

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to