diff --git a/dataFilter.py b/dataFilter.py index 2418f504f82533491d93bfa3cd7daaeac64e0e49..1653a760bd9067696dd26b1a857f6398c6b10d24 100755 --- a/dataFilter.py +++ b/dataFilter.py @@ -12,8 +12,9 @@ # print more info: # nLines before coolOff # nLines after coolOff -# nLines after cutOff (total nDel lines) # +# compat /w ecoTrack ? 1nt3gr4t3. + import sys, os cutOff=True @@ -25,6 +26,7 @@ COL_Y=COL_X+1 COL_TAG=COL_Y+1 DELIM="," +OMIT_COL_BEGIN=4 #omit ts,ms,date,time OUT_COL_X=5 OUT_COL_Y=OUT_COL_X+1 OUT_COL_TAG=OUT_COL_Y+1 @@ -39,8 +41,8 @@ def squash(data): for line in data: if line[0] == '#': if line.startswith("#timestamp"): - HEADER = line - filtered += HEADER + header="#begin, end, dur," + DELIM.join(line.split(',')[OMIT_COL_BEGIN:]) + filtered.append(header) continue l = line.split(DELIM) @@ -58,7 +60,6 @@ def squash(data): recentBeetle=recent[i][OUT_COL_TAG] == tag fastBeetle = not samePos and recentBeetle ago = timestamp - recent[i][1] - if ago > coolOff or fastBeetle: ## add new squashed / trackevent @@ -80,15 +81,17 @@ def squash(data): if not tagFound: ## add recent - recent.append([timestamp,timestamp,0]+l[4:]) #omit ts,ms,date,time + recent.append([timestamp,timestamp,0]+l[OMIT_COL_BEGIN:]) - ## cutOff ncut = 0 for r in recent: + + ## cutOff if cutOff: r[1] = r[0] ncut += r[2] r[2] = 0 + filtered.append(DELIM.join(map(str,r))) if cutOff: @@ -111,9 +114,7 @@ def main(filename): with open(filename) as f: data = f.readlines() - print(len(data)) data = squash( data ) - print(len(data)) write(filename + "-filtered", data)