Last active
September 29, 2018 11:26
-
-
Save FrankBuss/33edc1ac2a07f58632894dabc3459131 to your computer and use it in GitHub Desktop.
merge two c2d (Carbid Create) files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import json | |
import argparse | |
# parse command line arguments | |
parser = argparse.ArgumentParser() | |
parser.add_argument('master') | |
parser.add_argument('file_to_merge') | |
parser.add_argument('output_file') | |
args = parser.parse_args() | |
# read first file | |
with open(args.master) as f: | |
master = json.load(f) | |
# read file to merge | |
with open(args.file_to_merge) as f: | |
file_to_merge = json.load(f) | |
# add all items from the second file to the first file, except the document properties | |
for key, item in file_to_merge.items(): | |
if (key != 'DOCUMENT_VALUES') and (key in master): | |
master[key].extend(item) | |
# save result | |
with open(args.output_file, 'w') as f: | |
json.dump(master, f, indent=4, sort_keys=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment