You need to ignore empty lines.<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">for line in open('1.txt'):</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">    if len(line.strip()) == 0:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        continue</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">    columns = line.split()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    print columns[0], columns[2] </span><br>

<br>Cheers,<br>Xav<br><br><div class="gmail_quote">On Thu, May 6, 2010 at 6:22 PM, mannu jha <span dir="ltr"><<a href="mailto:mannu_0523@rediffmail.com">mannu_0523@rediffmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Hi,<br>
<br>
I have few files like this:<br>
<br>
24 ALA  helix (helix_alpha, helix2)<br>
<br>
<br>
27 ALA  helix (helix_alpha, helix2)<br>
<br>
<br>
51 ALA  helix (helix_alpha, helix4)<br>
<br>
<br>
58 ALA  helix (helix_alpha, helix5)<br>
<br>
<br>
63 ALA  helix (helix_alpha, helix5)<br>
<br>
now with this program:<br>
<br>
for line in open('1.txt'):<br>
       columns = line.split()<br>
       print columns[0], columns[2] <br>
<br>
I am trying to print only 1st and third column but it showing error like:<br>
mruser@caf:~> python split.py<br>
24 helix<br>
Traceback (most recent call last):<br>
  File "split.py", line 3, in <br>
    print columns[0], columns[2]<br>
IndexError: list index out of range<br>
nmruser@caf:~><br>
 how to rectify it.<br>
<br>
Thanks,<br>
<br><br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br>