I'm attempting to check GPS epochs (epochs.txt) against a range of times (strip-ranges.txt) to see how many epochs occurred during these times. However, I'm having trouble getting the inside loop to iterate. Here's a sample of my 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
for aLine in epochs:#outside for loop
GPS = aLine
for row in strips: #inside (nested) loop- loops bad epoch against strips
val = row.split(",") #splits strips into two values per line
stripA = float(val[0]) #start time of strip
stripB = float(val[1]) #end time of strip
if stripA <= GPS <= stripB: #if the epoch from Bad-epochs.txt is between the start and end time, adds 1 to counter
counter += 1 #adds to counter
else:
pass
print "The final count is %i" %counter
Every time I run the code, the counter is still at 0, although I know there should be around 100-150 GPS epochs that fall between the strip ranges. I've tried just opening the 'strips' file and using strips.seek(0) before the second for loop, to no avail. I realize there have been similar questions to this posted before, but none of the questions I've searched have yielded any answers that work. Thanks for any help or advice.
Aucun commentaire:
Enregistrer un commentaire