-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2_merge.py
34 lines (26 loc) · 844 Bytes
/
2_merge.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 2つのMessagePack形式ファイルを結合する。
# [[...], ...] + [[...], ...] -> [[...], ...]
import sys
import msgpackutil
if len(sys.argv) <= 3:
print("Usage: " + sys.argv[0] + " infile1 infile2 outfile", file=sys.stderr)
exit(1)
infile1 = sys.argv[1]
infile2 = sys.argv[2]
outfile = sys.argv[3]
print("infile1 = " + infile1)
print("infile2 = " + infile2)
print("outfile = " + outfile)
print("loading...")
in_records1 = msgpackutil.load(infile1)
in_records2 = msgpackutil.load(infile2)
print("processing...")
out_records = []
out_records.extend(in_records1)
out_records.extend(in_records2)
print("in_records1.len = " + str(len(in_records1)))
print("in_records2.len = " + str(len(in_records2)))
print("out_records.len = " + str(len(out_records)))
print("dumping...")
msgpackutil.dump(outfile, out_records)
print("ok")