Here is an example of my input csv file:
...
0.7,0.5,0.35,14.4,0.521838919218
0.7,0.5,0.35,14.4,0.521893472678
0.7,0.5,0.35,14.4,0.521948026139
0.7,0.5,0.35,14.4,0.522002579599
...
I need to select the top row where the last float > random number. My current implementation is very slow (script has a lot of iterations of this and outer cycles):
for line in foo:
if float(line[-1]) > random.random():
res = line
break
...
How can I make this better and faster?
EDIT:
I was advised to use bisect for this task, but I don't know how to do it.