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

dataFilter: fix header

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