mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
added file-filter python script and README
This commit is contained in:
parent
36607c8d4c
commit
74784073cd
3 changed files with 35 additions and 0 deletions
1
contrib/python/.gitignore
vendored
Normal file
1
contrib/python/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.pyc
|
11
contrib/python/README.md
Normal file
11
contrib/python/README.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Python tools
|
||||
|
||||
These python scripts are intended to manipulate measurements recorded by S2SS's `file` node-type.
|
||||
|
||||
## Exampples
|
||||
|
||||
##### Merge two files and filter the output based on timestamps
|
||||
|
||||
```
|
||||
./file-merge.py testfile.dat testfile2.dat | ./file-filter.py 3 5 > output.dat
|
||||
```
|
23
contrib/python/file-filter.py
Executable file
23
contrib/python/file-filter.py
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
import s2ss
|
||||
from s2ss import *
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 3:
|
||||
print "Usage: %s from to" % (sys.argv[0])
|
||||
sys.exit(-1)
|
||||
|
||||
start = s2ss.Timestamp.parse(sys.argv[1])
|
||||
end = s2ss.Timestamp.parse(sys.argv[2])
|
||||
|
||||
for line in sys.stdin:
|
||||
msg = s2ss.Message.parse(line)
|
||||
|
||||
if start <= msg.ts <= end:
|
||||
print msg
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Add table
Reference in a new issue