Re: Re: column selection

2010-05-07 Thread mannu jha
On Fri, 07 May 2010 18:58:59 +0530 wrote >mannu jha wrote: > On Thu, 06 May 2010 18:54:59 +0530 wrote > >> mannu jha wrote: >> > > >> I tried with this: >> > > > > >> for line in open('1.txt'): >> > > >> columns = line.split() >> > > >> print column

Re: Re: column selection

2010-05-07 Thread Dave Angel
Dave Angel wrote: mannu jha wrote: I tried with this: for line in open('1.txt'): columns = line.split() print columns[0], columns[1] if not line: continue but it is showing error: nmru...@caf:~> python split.py 24 ALA Traceback (most recent call last): File "split.py",

Re: column selection

2010-05-06 Thread Dave Angel
mannu jha wrote: I tried with this: for line in open('1.txt'): columns = line.split() print columns[0], columns[1] if not line: continue but it is showing error: nmru...@caf:~> python split.py 24 ALA Traceback (most recent call last): File "split.py", line 3, in pri

Re: Re: column selection

2010-05-06 Thread mannu jha
I tried with this: for line in open('1.txt'): columns = line.split() print columns[0], columns[1] if not line: continue but it is showing error: nmru...@caf:~> python split.py 24 ALA Traceback (most recent call last): File "split.py", line 3, in print columns[0], col

Re: column selection

2010-05-06 Thread Dave Angel
mannu jha wrote: Hi, I have few files like this: 24 ALA helix (helix_alpha, helix2) 27 ALA helix (helix_alpha, helix2) 51 ALA helix (helix_alpha, helix4) 58 ALA helix (helix_alpha, helix5) 63 ALA helix (helix_alpha, helix5) now with this program: for line in open('1.txt'):

Re: column selection

2010-05-06 Thread Xavier Ho
You need to ignore empty lines. for line in open('1.txt'): if len(line.strip()) == 0: continue columns = line.split() print columns[0], columns[2] Cheers, Xav On Thu, May 6, 2010 at 6:22 PM, mannu jha wrote: > Hi, > > I have few files like this: > > 24 ALA helix (helix_alph