import json, sys # Read 2 filenames from command line # Output to stdout features in file2 not in file1 if len(sys.argv) == 1: print "Must provide 2 command line arguments" print 'Number of arguments:', len(sys.argv)-1 exit with open(sys.argv[1], "r") as read_file: j = json.load(read_file) features1 = j["features"] # Create a set of ID's from first file of features alpha = set() for f in features1: alpha.add(f["id"]); with open(sys.argv[2], "r") as read_file: j = json.load(read_file) features2 = j["features"] # Lookup each feature ID from file2 in set bravo = [] for f in features2: target = f["id"] if target not in alpha: bravo.append(target); # bravo contains items in dat2 not in dat1 for b in bravo: print b # Note features dicts are saved for future use