Trouble performing if statement inside a nested loop in python using two text files -
i'm attempting check gps epochs (epochs.txt) against range of times (strip-ranges.txt) see how many epochs occurred during these times. however, i'm having trouble getting inside loop iterate. here's sample of code:
import os epochs = open("c:\\users\\bcox\\documents\\bad-epochs.txt", "r").readline() strips = open("c:\\users\\bcox\\documents\\strip-ranges.txt","r").readlines() counter = 0 #create counter object aline in epochs:#outside loop gps = aline row in strips: #inside (nested) loop- loops bad epoch against strips val = row.split(",") #splits strips 2 values per line stripa = float(val[0]) #start time of strip stripb = float(val[1]) #end time of strip if stripa <= gps <= stripb: #if epoch bad-epochs.txt between start , end time, adds 1 counter counter += 1 #adds counter else: pass print "the final count %i" %counter
every time run code, counter still @ 0, although know there should around 100-150 gps epochs fall between strip ranges. i've tried opening 'strips' file , using strips.seek(0) before second loop, no avail. realize there have been similar questions posted before, none of questions i've searched have yielded answers work. or advice.
Comments
Post a Comment