0

I'm trying to filter a large tab delimited file and print out just the lines with a score of >0.999 in one of the columns, but for some reason script's output continues to just print every line. Any insights as to why my "if score > 0.999:" isn't working as intended?

import sys
import string
import re


def split_lines(lines):
for line in lines:
    if line.find('#') >-1:

        print line
    else:
        #pass
        #fields = re.split('\t',line)
        fields = line.split('\t')
        score = fields[3]
        if score > 0.999:
            print score

        #else:
        #   pass



data = sys.stdin.read()
lines = data.split('\n')

split_lines(lines)
1
  • Does your script know that your incoming data is numerical? Commented Jun 13, 2013 at 22:24

1 Answer 1

3

You need to convert the string score to a number format, Decimal or float

if float(score) > 0.999
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.