forked from aquirozsea/c4v
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmerge.py
More file actions
executable file
·26 lines (23 loc) · 754 Bytes
/
merge.py
File metadata and controls
executable file
·26 lines (23 loc) · 754 Bytes
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
#!/usr/bin/env python
from filetools import JsonReader, Writer
import sys
def merge(with_medicines, with_locations):
if with_medicines["medicines"] and with_locations["locations"]:
with_medicines["locations"] = with_locations["locations"]
return with_medicines
return None
if __name__ == '__main__':
with_medicines_file = sys.argv[1]
with_locations_file = sys.argv[2]
iter_m = JsonReader(with_medicines_file).lines()
iter_l = JsonReader(with_locations_file).lines()
writer = Writer(sys.argv[3])
try:
while True:
with_medicines = iter_m.next()
with_locations = iter_l.next()
merged = merge(with_medicines, with_locations)
if merged:
writer.write_json(merged)
except StopIteration:
pass