From cd17c17fd80f6d95e04e88e484faebab709f0c9f Mon Sep 17 00:00:00 2001 From: am0ebe <am0ebe@gmx.de> Date: Thu, 4 Feb 2021 23:11:23 +0100 Subject: [PATCH] dataFilter: fix header --- dataFilter.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/dataFilter.py b/dataFilter.py index 2418f50..1653a76 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) -- GitLab