Re: [Tutor] please help: conditional statement and printing element

2005-01-11 Thread Alan Gauld
e help: conditional statement and printing element > Quoting kumar s <[EMAIL PROTECTED]>: > > > What to do: > > I want to print values that are 25 in column 1 and not > > the other values such as 24,22,21 etc. > >

Re: [Tutor] please help: conditional statement and printing element

2005-01-11 Thread jfouhy
Quoting kumar s <[EMAIL PROTECTED]>: > What to do: > I want to print values that are 25 in column 1 and not > the other values such as 24,22,21 etc. awk '$1 == 25' psl :-) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailma

Re: [Tutor] please help: conditional statement and printing element

2005-01-11 Thread kumar s
Dear group: I think I have got the answer :-)( script: >>> for i in range(len(psl)): col = split(psl[i],'\t') col1 = col[0] col1 = int(col1) col17 = int(col[17]) if col1 == 25 and col17 == 1: print col[0]+ '\t'+col[1]+'\t'+col[9]+'\t'+col[

Re: [Tutor] please help: conditional statement and printing element

2005-01-11 Thread Jacob S.
coll is a string, 25 is an integer. However, I would do it this way. file1 = open('psl.txt','r') for line in file1: if line.startwith('25'): line = line.split('\t') print "\t".join(line[0],line[1],line[17]) file1.close() This has the added advantage that if you have a big fil

Re: [Tutor] please help: conditional statement and printing element

2005-01-11 Thread Alan Gauld
> script: > >>> for i in range(len(psl)): for line in psl: if line.split()[0].strip() == '25': print line Does that work? Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] please help: conditional statement and printing element

2005-01-11 Thread Jacob S.
I think I speak for a few of us in the fact that we don't know if that's close to the correct approach due to the fact that you haven't given us a full line to look at. Is col[17] the last column? If so, take the code I just sent and change the line to: if line.startwith('25\t') and line.endswith(

Re: [Tutor] please help: conditional statement and printing element

2005-01-11 Thread Kent Johnson
kumar s wrote: Dear group, For some reason my brain cannot think of any other option than what I have in my script. Could any one please help me in suggesting. What I have : (File name : psl) 22 2 457:411 25 0 25 0 457:411 25 0 25 0 457:411 25 0 2

[Tutor] please help: conditional statement and printing element

2005-01-11 Thread kumar s
Dear group, For some reason my brain cannot think of any other option than what I have in my script. Could any one please help me in suggesting. What I have : (File name : psl) 22 2 457:411 25 0 25 0 457:411 25 0 25 0 457:411 25 0 25 0