Skip to content

Instantly share code, notes, and snippets.

@FrankBuss
Last active September 29, 2018 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FrankBuss/33edc1ac2a07f58632894dabc3459131 to your computer and use it in GitHub Desktop.
Save FrankBuss/33edc1ac2a07f58632894dabc3459131 to your computer and use it in GitHub Desktop.
merge two c2d (Carbid Create) files
#!/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