Skip to content
Snippets Groups Projects
Commit cd17c17f authored by am0ebe's avatar am0ebe
Browse files

dataFilter: fix header

parent b2dd2d68
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment