Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ecotronData
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kr69sugu
ecotronData
Commits
a2813bf7
Commit
a2813bf7
authored
4 years ago
by
am0ebe
Browse files
Options
Downloads
Patches
Plain Diff
add time since last detection col
parent
cd17c17f
Branches
new-data
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dataFilter.py
+38
-4
38 additions, 4 deletions
dataFilter.py
with
38 additions
and
4 deletions
dataFilter.py
+
38
−
4
View file @
a2813bf7
...
@@ -41,8 +41,8 @@ def squash(data):
...
@@ -41,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
=
"
#begin, end, dur,
"
+
DELIM
.
join
(
line
.
split
(
'
,
'
)[
OMIT_COL_BEGIN
:])
global
header
filtered
.
append
(
header
)
header
=
"
#begin, end, dur, last detect, PXE,
"
+
DELIM
.
join
(
line
.
split
(
'
,
'
)[
OMIT_COL_BEGIN
:]
)
continue
continue
l
=
line
.
split
(
DELIM
)
l
=
line
.
split
(
DELIM
)
...
@@ -91,7 +91,7 @@ def squash(data):
...
@@ -91,7 +91,7 @@ def squash(data):
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
:
...
@@ -99,11 +99,42 @@ def squash(data):
...
@@ -99,11 +99,42 @@ def squash(data):
return
filtered
return
filtered
def
add_lastDetect_and_PXE
(
data
):
"
add
'
time since last detection
'
and
'
patch-Cross-Event
'"
OUT_COL_END
=
1
OUT_COL_LASTDETECT
=
3
OUT_COL_PXE
=
4
known
=
{}
#{tag: line}
for
i
,
line
in
enumerate
(
data
):
l
=
line
.
split
(
DELIM
)
tag
=
l
[
OUT_COL_TAG
]
if
tag
not
in
known
:
l
.
insert
(
OUT_COL_LASTDETECT
,
"
NA
"
)
# l.insert(OUT_COL_PXE,"TODO")
else
:
last_end
=
int
(
known
[
tag
][
OUT_COL_END
])
this_start
=
int
(
l
[
OUT_COL_END
])
l
.
insert
(
OUT_COL_LASTDETECT
,
this_start
-
last_end
)
known
[
tag
]
=
l
data
[
i
]
=
DELIM
.
join
(
map
(
str
,
l
))
return
data
def
write
(
outFile
,
data
):
def
write
(
outFile
,
data
):
print
(
f
"
writing to
{
outFile
}
"
)
print
(
f
"
writing to
{
outFile
}
"
)
with
open
(
outFile
,
"
w
"
)
as
f
:
with
open
(
outFile
,
"
w
"
)
as
f
:
f
.
writelines
(
header
)
f
.
writelines
(
data
)
f
.
writelines
(
data
)
# cmd_compress=f"tar -zcvf {outFile}.tgz {outFile}" # ">/dev/null 2>/dev/null"
# cmd_compress=f"tar -zcvf {outFile}.tgz {outFile}" # ">/dev/null 2>/dev/null"
...
@@ -115,8 +146,11 @@ def main(filename):
...
@@ -115,8 +146,11 @@ def main(filename):
data
=
f
.
readlines
()
data
=
f
.
readlines
()
data
=
squash
(
data
)
data
=
squash
(
data
)
write
(
filename
+
"
-filtered-squashed
"
,
data
)
data
=
add_lastDetect_and_PXE
(
data
)
write
(
filename
+
"
-filtered
"
,
data
)
write
(
filename
+
"
-filtered
-added
"
,
data
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment