Advertisement
Bicorn

small Finnish CoViD-19 case data analyser

Mar 14th, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. # -*- coding: UTF-8 -*-
  2.  
  3. import urllib, json
  4.  
  5. url = "https://w3qa5ydb4l.execute-api.eu-west-1.amazonaws.com/prod/finnishCoronaData"
  6. caseData = json.load(urllib.urlopen(url))
  7.  
  8. confirmed = caseData['confirmed']
  9. print("Total: " + str(len(confirmed)))
  10.  
  11. def count_em(lst, key):
  12.     labels = {}
  13.     unk = 0
  14.     for case in lst:
  15.         la = case.get(key)
  16.         if la:
  17.             labels[la] = 1 + labels.get(la,0)
  18.         else:
  19.             unk += 1
  20.     for k, v in sorted(labels.items(), key=lambda t: t[0]):
  21.         print("  " + k + ": " + str(v))
  22.     if unk:
  23.         print("  UNKNOWN: " + str(unk))
  24.  
  25. print("Area:")
  26. count_em(confirmed, 'healthCareDistrict')
  27.  
  28. print("Source country:")
  29. count_em(confirmed, 'infectionSourceCountry')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement