Created
February 27, 2018 08:09
-
-
Save shreyansh26/68288cff647b17b45752c6c4602d2fea 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
f = open('file-20171020T1500.json', 'r') | |
import json | |
import operator | |
dc = {} | |
dc_n = {} | |
for l in f: | |
j = json.loads(l) | |
scans = j["scans"] | |
for i in scans: | |
if scans[i]["detected"] == True: | |
if i in dc.keys(): | |
dc[i] += 1 | |
else: | |
dc[i] = 1 | |
elif scans[i]["detected"] == False: | |
if i in dc_n.keys(): | |
dc_n[i] += 1 | |
else: | |
dc_n[i] = 1 | |
d2 = {} | |
for i in dc.keys(): | |
d2[i] = dc[i] / (dc[i]+dc_n[i]) | |
d2 = sorted(d2.items(), key=operator.itemgetter(1)) | |
for k, v in d2: | |
print(k, v) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment