[Tutor] creating a regularly placed fields in a line

Bala subramanian bala.biophysics at gmail.com
Wed Apr 25 17:17:04 CEST 2012

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:
        bond.write('   %s\t%s\t%s\t%s\t%s\n' % (p1,p2,p3,p4,new) )

C. Balasubramanian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120425/d22ac614/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.output
Type: application/octet-stream
Size: 1025 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20120425/d22ac614/attachment.obj>

More information about the Tutor mailing list