diff --git a/contrib/python/.gitignore b/contrib/python/.gitignore new file mode 100644 index 000000000..0d20b6487 --- /dev/null +++ b/contrib/python/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/contrib/python/README.md b/contrib/python/README.md new file mode 100644 index 000000000..a12819265 --- /dev/null +++ b/contrib/python/README.md @@ -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 +``` diff --git a/contrib/python/file-filter.py b/contrib/python/file-filter.py new file mode 100755 index 000000000..c7eefd294 --- /dev/null +++ b/contrib/python/file-filter.py @@ -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()