Dear Sir, Thanks for your help..........but yes my files are having column like:
# RESIDUE AA STRUCTURE BP1 BP2 ACC N-H-->O O-->H-N N-H-->O O-->H-N TCO KAPPA ALPHA PHI PSI X-CA Y-CA Z-CA 1 2 A I 0 0 91 0, 0.0 38,-0.1 0, 0.0 5,-0.0 0.000 360.0 360.0 360.0 156.1 38.1 24.6 -5.0 2 3 A R >> - 0 0 86 1,-0.1 4,-1.8 38,-0.1 3,-1.0 -0.377 360.0-116.9 -66.2 144.2 35.1 25.2 -7.3 3 4 A P H 3> S+ 0 0 81 0, 0.0 4,-2.7 0, 0.0 5,-0.2 0.843 111.7 60.4 -55.3 -36.8 34.6 28.8 -8.2 and in the output I want just: 2 A I 3 A R >> - 4 A P H 3> S+ i.e. residue no., aa and seconday structure. Thanks On Mon, 26 Apr 2010 20:40:55 +0530 wrote >mannu jha wrote: > Dear all, > > I am new in python, can anyone help me that how can I select two > column out of 6 column from a file. > For example if I have file like: > > a1 a2 a3 a4 a5 a6 > b1 b2 b3 b4 b5 b6 > c1 c2 c3 c4 c5 c6 > d1 d2 d3 d4 d5 d6 > > and I want output like: > > a1 a4 > b1 b4 > c1 c4 > d1 d4 > > then how to do > > Thanks Do you know how to open a file, and how to read individual lines from it? If so, then you can split a line at the spaces into a list by using fields = line.split() Then print fields[0], fields[3] would do what you ask. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list
-- http://mail.python.org/mailman/listinfo/python-list