Skip to content

Instantly share code, notes, and snippets.

@tgflynn
Created November 3, 2016 00:14
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 tgflynn/72af920815c3ef63dfc74d587675d9d0 to your computer and use it in GitHub Desktop.
Save tgflynn/72af920815c3ef63dfc74d587675d9d0 to your computer and use it in GitHub Desktop.
#!/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
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
print
diffcount += 1
print "diffcount = ", diffcount
print
print
print "Missing objects:"
for key in missingkeys:
print "key = ", key
for js in jsons:
if key in js:
print js[key]
break
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment