Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import json, glob, os, sys
  4. path = os.path.realpath(__file__)
  5. path = os.path.split(path)[0]
  6. #print(path,__file__)
  7.  
  8. json_files = glob.glob(os.path.join(path,"*.json"))
  9. #print(json_files)
  10.  
  11. json_objs = []
  12. for filename in json_files:
  13.   with open(filename,"r") as fd:
  14.     json_objs.append(json.load(fd))
  15. #print(json_objs)
  16.  
  17. output = {}
  18. for obj in json_objs:
  19.   for section in obj.keys():
  20.     if section not in output.keys():
  21.       output[section] = []
  22.     for item in obj[section]:
  23.       if item not in output[section]:
  24.         output[section].append(item)
  25.  
  26. json.dump(output,sys.stdout,indent=2)
  27. sys.stdout.write("\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement