From what I can gather, this does what you're asking...
#!/usr/bin/env python
import csv
value = 1.42
out = open("test.csv","rU")
dataf=csv.reader(out, delimiter=',')
matches = [float(row[0]) >= value for row in dataf]
matches.reverse()
for i,m in enumerate(matches):
if m:
print i
matches
is a list of boolean values, that shows whether the first column in each row is greater than value
. It looks like you want to order from the bottom up, so I reverse
d the list. The loop prints the index of the (reversed) list if the value in the first column was greater than or equal to value
.
value = 1.42
output:
0
1
value = 1.4
output:
0
1
2
value = 1.45
no output.