1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00
VILLASnode/tools/python/file-merge.py

36 lines
613 B
Python
Raw Permalink Normal View History

#!/usr/bin/env python
import sys
2016-06-08 23:21:42 +02:00
import villas
from villas import *
def main():
files = sys.argv[1:]
all = [ ]
last = { }
for file in files:
handle = sys.stdin if file == '-' else open(file, "r")
msgs = [ ]
for line in handle.xreadlines():
2016-06-08 23:21:42 +02:00
msgs.append(villas.Message.parse(line, file))
all += msgs
2016-06-08 23:21:42 +02:00
last[file] = villas.Message(villas.Timestamp(), [0] * len(msgs[0].values), file)
all.sort()
for msg in all:
last[msg.source] = msg
values = [ ]
for file in files:
values += last[file].values
2016-06-08 23:21:42 +02:00
print villas.Message(msg.ts, values, "")
if __name__ == "__main__":
main()