I have the following python function that takes an input of directory and the file name.
It reads from a CSV file which can have a line with 'null' as the value.
tps.csv 1 2 3 4 null 5 6
The moment it reads 'null' from the csv, it gives me an error (below) even though I have an if condition to skip when it reads 'null.'
ValueError: could not convert string to float: null
Code:
def computeMean(dir_name, filename):
    csv_filename = '{}/{}'.format(dir_name, filename)
    numbers = []
    with open(csv_filename) as f:
        for line in f:
            if line is not 'null':
                number_on_line = float(line)
                numbers.append(number_on_line)
    return sum(numbers)/len(numbers)
What do I need to add or change so that it ignores/skips non-numerical values?
 
     
     
     
    