Skip to content

Instantly share code, notes, and snippets.

@FrankBuss FrankBuss/merge-c2d.py
Last active Sep 29, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.