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

29 lines
510 B
Python
Executable file

#!/usr/bin/env python
import sys
import villas.human
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():
msgs.append(vh.Message.parse(line, file))
all += msgs
last[file] = vh.Message(vh.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
print(vh.Message(msg.ts, values, ""))