Created
November 3, 2016 00:14
-
-
Save tgflynn/72af920815c3ef63dfc74d587675d9d0 to your computer and use it in GitHub Desktop.
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/env python | |
import sys | |
import os | |
import json | |
paths = sys.argv[1:] | |
ifiles = [ file( path ) for path in paths ] | |
datasets = [ ifile.read() for ifile in ifiles ] | |
jsons = [ json.loads( data ) for data in datasets ] | |
allkeys = set() | |
for i in range( len( jsons ) ): | |
js = jsons[i] | |
keys = js.keys() | |
allkeys = allkeys.union( set( keys ) ) | |
print "File: ", i | |
print "Number objects: ", len( keys ) | |
print "Total number keys: ", len( allkeys ) | |
missingkeys = set() | |
for i in range( len( jsons ) ): | |
js = jsons[i] | |
keys = js.keys() | |
print "File: ", i | |
diffcount = 0 | |
for key in allkeys: | |
if key not in keys: | |
missingkeys = missingkeys.union( set( [ key ] ) ) | |
print key | |
diffcount += 1 | |
print "diffcount = ", diffcount | |
print "Missing objects:" | |
for key in missingkeys: | |
print "key = ", key | |
for js in jsons: | |
if key in js: | |
print js[key] | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment