Skip to content

Instantly share code, notes, and snippets.

@AdamZWinter
Created October 22, 2020 23:29
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 AdamZWinter/576d2bf31cccad8a7c9ad9744f67d63d to your computer and use it in GitHub Desktop.
Save AdamZWinter/576d2bf31cccad8a7c9ad9744f67d63d to your computer and use it in GitHub Desktop.
#! /usr/bin/env python2.7
import json
import glob
import copy
producers = []
for filename in glob.glob('new/*.json'):
fileobj = open(filename, "r")
stringContents = fileobj.read()
jsonObj = json.loads(stringContents)
producers = producers + jsonObj["Producers"]
unique = [producers[0]]
data = {}
data['Producers'] = []
for producer in producers:
matches = 0
for element in unique:
if producer["addr"] == element["addr"] and producer["port"] == element["port"]:
matches = 1
break
if matches == 0:
data['Producers'].append(producer)
new = [producer]
unique = unique + new
with open('testnext-topology.json', 'w') as outfile:
json.dump(data, outfile, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment