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.
>
>
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
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[
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
> 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
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(
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
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