iERP-ai / businesswithcovid-generator

Script generating data for the businesswithcorona.com - generatorrrr
http://businesswithcorona.com
0 stars 0 forks source link

Generate country json files using score and healh data #1

Closed flesicek closed 4 years ago

flesicek commented 4 years ago

Currently, the score is calculated correctly but only printed to console.

Expected functionality:

  1. score which is printed to console please store into an array in memory
  2. create loop for each country from country.json file (the file has been committed to repo)
  3. for each country generate new json file on file system (naming convention: country-data-[country code from countries.json, for example svk or usa].json
  4. data in different sections of the file should be filled in in following way:
    • limitations - this is array of limitations from last available row from Oxford data set. Please create a function which will receive column name and value. I will create conditions to generate coresponding 5 values for it
    • scores: for now fill in iERPScoreBNow with last score for specific country
    • graphs.iERPScoreB.history : is list of scores which you calculated for specific country. date format should be yyyy-mm-dd
    • graphs.iERPScoreB.forecast : skip for now
    • graphs.iERPScoreH : skip
    • graphs.cases.history: is list of cases from github repo for specific country. date format should be yyyy-mm-dd
    • graphs.cases.forecast: skip for now
    • graphs.deaths.history: is list of deaths from github repo for specific country. date format should be yyyy-mm-dd
    • graphs.cases.forecast: skip for now

example country JSON file:

{
   "limitations":[
      {
         "name":"Restrictions of travel",
         "value":"Applied selectively",
         "icon":"RocketOutlined",
         "ColorB":"#fff",
         "ColorT":"#000"
      },
      {
         "name":"School closing",
         "value":"General",
         "icon":"PictureOutlined",
         "ColorB":"#fff",
         "ColorT":"#000"
      }
   ],
   "scores":{
      "iERPScoreBNow":0,
      "iERPScoreBDays7":0,
      "iERPScoreBDays14":0,
      "iERPScoreBDays21":0
   },
   "graphs":{
      "iERPScoreB":{
         "history":[
            {
               "d":"2019-10-01",
               "iERPScoreB":4
            },
            {
               "d":"2019-10-02",
               "iERPScoreB":5
            },
            {
               "d":"2019-10-03",
               "iERPScoreB":6
            }
         ],
         "forecast":[
            {
               "d":"2019-10-04",
               "iERPScoreB":4
            },
            {
               "d":"2019-10-05",
               "iERPScoreB":5
            },
            {
               "d":"2019-10-06",
               "iERPScoreB":6
            }
         ]
      },
      "iERPScoreH":{
         "history":[
            {
               "d":"2019-10-01",
               "iERPScoreH":4
            },
            {
               "d":"2019-10-02",
               "iERPScoreH":5
            },
            {
               "d":"2019-10-03",
               "iERPScoreH":6
            }
         ],
         "forecast":[
            {
               "d":"2019-10-04",
               "iERPScoreH":4
            },
            {
               "d":"2019-10-05",
               "iERPScoreH":5
            },
            {
               "d":"2019-10-06",
               "iERPScoreH":6
            }
         ]
      },
      "cases":{
         "history":[
            {
               "d":"2019-10-01",
               "cases":4
            },
            {
               "d":"2019-10-02",
               "cases":5
            },
            {
               "d":"2019-10-03",
               "cases":6
            }
         ],
         "forecast":[
            {
               "d":"2019-10-04",
               "cases":4
            },
            {
               "d":"2019-10-05",
               "cases":5
            },
            {
               "d":"2019-10-06",
               "cases":6
            }
         ]
      },
      "deaths":{
         "history":[
            {
               "d":"2019-10-01",
               "deaths":4
            },
            {
               "d":"2019-10-02",
               "deaths":5
            },
            {
               "d":"2019-10-03",
               "deaths":6
            }
         ],
         "forecast":[
            {
               "d":"2019-10-04",
               "deaths":4
            },
            {
               "d":"2019-10-05",
               "deaths":5
            },
            {
               "d":"2019-10-06",
               "deaths":6
            }
         ]
      }
   }
}
tommycarstensen commented 4 years ago

I will probably not use the file countries.json but rather the python module pycountry, because there is a discrepancy between country names; i.e. official and non-official. For example Slovakia and Slovak Republic.

tommycarstensen commented 4 years ago

In the case of countries with overseas territories and subdivided into regions I will sum across these subregions: Canada: Subtract "Grand Princess", "Diamond Princess" and "Recovered" China: Subtract Hong Kong and Tibet and do not add Taiwan Denmark: Subtract Faroe Islands and Greenland France: Do not subtract overseas territories Netherlands: Do not subtract overseas territories UK: Do not subtract overseas territories

              Province/State Country/Region      Lat      Long  1/22/20  1/23/20  1/24/20  1/25/20  1/26/20  ...  3/31/20  4/1/20  4/2/20  4/3/20  4/4/20  4/5/20  4/6/20  4/7/20  4/8/20

8 Australian Capital Territory Australia -35.4735 149.0124 0 0 0 0 0 ... 80 84 87 91 93 96 96 96 99 9 New South Wales Australia -33.8688 151.2093 0 0 0 0 3 ... 2032 2182 2298 2389 2493 2580 2637 2686 2734 10 Northern Territory Australia -12.4634 130.8456 0 0 0 0 0 ... 17 19 21 22 26 27 28 28 28 11 Queensland Australia -28.0167 153.4000 0 0 0 0 0 ... 743 781 835 873 900 907 921 934 943 12 South Australia Australia -34.9285 138.6007 0 0 0 0 0 ... 337 367 367 396 407 407 411 411 415 13 Tasmania Australia -41.4545 145.9707 0 0 0 0 0 ... 69 69 72 74 80 82 86 89 98 14 Victoria Australia -37.8136 144.9631 0 0 0 0 1 ... 917 968 1036 1085 1115 1135 1158 1191 1212 15 Western Australia Australia -31.9505 115.8605 0 0 0 0 0 ... 364 392 400 400 436 453 460 460 481

[8 rows x 82 columns] Province/State Country/Region Lat Long 1/22/20 1/23/20 1/24/20 1/25/20 1/26/20 ... 3/31/20 4/1/20 4/2/20 4/3/20 4/4/20 4/5/20 4/6/20 4/7/20 4/8/20 35 Alberta Canada 53.9333 -116.5765 0 0 0 0 0 ... 690 754 969 969 1075 1181 1250 1373 1373 36 British Columbia Canada 49.2827 -123.1207 0 0 0 0 0 ... 1013 1013 1121 1174 1203 1203 1266 1266 1291 37 Grand Princess Canada 37.6489 -122.6655 0 0 0 0 0 ... 13 13 13 13 13 13 13 13 13 38 Manitoba Canada 53.7609 -98.8139 0 0 0 0 0 ... 103 127 167 182 182 203 203 217 217 39 New Brunswick Canada 46.5653 -66.4619 0 0 0 0 0 ... 70 81 91 91 91 98 103 105 105 40 Newfoundland and Labrador Canada 53.1355 -57.6604 0 0 0 0 0 ... 152 175 183 195 195 217 226 228 228 41 Nova Scotia Canada 44.6820 -63.7443 0 0 0 0 0 ... 147 173 193 207 236 262 293 310 310 42 Ontario Canada 51.2538 -85.3232 0 0 0 0 1 ... 1966 2392 2793 3255 3630 4354 4347 4726 5276 43 Prince Edward Island Canada 46.5107 -63.4168 0 0 0 0 0 ... 21 21 22 22 22 22 22 22 25 44 Quebec Canada 52.9399 -73.5491 0 0 0 0 0 ... 4162 4611 5518 6101 6101 7944 8580 9340 10031 45 Saskatchewan Canada 52.9399 -106.4509 0 0 0 0 0 ... 184 193 206 220 220 249 249 260 260 231 Diamond Princess Canada 0.0000 0.0000 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 238 Recovered Canada 0.0000 0.0000 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 245 Northwest Territories Canada 64.8255 -124.8457 0 0 0 0 0 ... 1 2 2 2 4 4 5 5 5 246 Yukon Canada 64.2823 -135.0000 0 0 0 0 0 ... 5 5 6 6 6 6 6 7 7

[15 rows x 82 columns] Province/State Country/Region Lat Long 1/22/20 1/23/20 1/24/20 1/25/20 1/26/20 1/27/20 ... 3/30/20 3/31/20 4/1/20 4/2/20 4/3/20 4/4/20 4/5/20 4/6/20 4/7/20 4/8/20 49 Anhui China 31.8257 117.2264 1 9 15 39 60 70 ... 990 990 990 990 990 990 990 990 990 990 50 Beijing China 40.1824 116.4142 14 22 36 41 68 80 ... 577 580 580 582 584 585 586 587 587 588 51 Chongqing China 30.0572 107.8740 6 9 27 57 75 110 ... 579 579 579 579 579 579 579 579 579 579 52 Fujian China 26.0789 117.9874 1 5 10 18 35 59 ... 340 343 345 345 349 350 350 350 351 351 53 Gansu China 37.8099 101.0583 0 2 2 4 7 14 ... 138 138 138 138 138 138 138 139 139 139 54 Guangdong China 23.3417 113.4244 26 32 53 78 111 151 ... 1484 1494 1501 1507 1514 1516 1524 1532 1533 1536 55 Guangxi China 23.8298 108.7881 2 5 23 23 36 46 ... 254 254 254 254 254 254 254 254 254 254 56 Guizhou China 26.8154 106.8748 1 3 3 4 5 7 ... 146 146 146 146 146 146 146 146 146 146 57 Hainan China 19.1959 109.7453 4 5 8 19 22 33 ... 168 168 168 168 168 168 168 168 168 168 58 Hebei China 39.5490 116.1306 1 1 2 8 13 18 ... 321 321 323 325 326 326 327 327 327 327 59 Heilongjiang China 47.8620 127.7615 0 2 4 9 15 21 ... 484 484 484 488 489 491 504 524 544 569 60 Henan China 33.8820 113.6140 5 5 9 32 83 128 ... 1276 1276 1276 1276 1276 1276 1276 1276 1276 1276 61 Hong Kong China 22.3000 114.2000 0 2 2 5 8 8 ... 682 714 765 802 845 862 890 914 935 960 62 Hubei China 30.9756 112.2707 444 444 549 761 1058 1423 ... 67801 67801 67802 67802 67802 67803 67803 67803 67803 67803 63 Hunan China 27.6104 111.7088 4 9 24 43 69 100 ... 1018 1018 1018 1019 1019 1019 1019 1019 1019 1019 64 Inner Mongolia China 44.0935 113.9448 0 0 1 7 7 11 ... 97 107 111 117 117 117 117 118 121 124 65 Jiangsu China 32.9711 119.4550 1 5 9 18 33 47 ... 645 646 646 647 651 651 651 651 651 651 66 Jiangxi China 27.6140 115.7221 2 7 18 18 36 72 ... 937 937 937 937 937 937 937 937 937 937 67 Jilin China 43.6661 126.1923 0 1 3 4 4 6 ... 98 98 98 98 98 98 98 98 98 98 68 Liaoning China 41.2956 122.6085 2 3 4 17 21 27 ... 136 139 140 141 141 141 142 142 144 144 69 Macau China 22.1667 113.5500 1 2 2 2 5 6 ... 38 41 41 41 43 43 44 44 44 45 70 Ningxia China 37.2692 106.1655 1 1 2 3 4 7 ... 75 75 75 75 75 75 75 75 75 75 71 Qinghai China 35.7452 95.9956 0 0 0 1 1 6 ... 18 18 18 18 18 18 18 18 18 18 72 Shaanxi China 35.1917 108.8701 0 3 5 15 22 35 ... 253 253 255 255 255 256 256 256 256 256 73 Shandong China 36.3427 118.1498 2 6 15 27 46 75 ... 773 774 774 775 778 778 779 780 781 783 74 Shanghai China 31.2020 121.4491 9 16 20 33 40 53 ... 498 509 516 522 526 529 531 536 538 543 75 Shanxi China 37.5777 112.2922 1 1 1 6 9 13 ... 136 136 137 137 137 137 138 138 138 163 76 Sichuan China 30.6171 102.7103 5 8 15 28 44 69 ... 550 550 552 554 555 557 558 559 560 560 77 Tianjin China 39.3054 117.3230 4 4 8 10 14 23 ... 174 174 176 176 180 180 180 180 180 180 78 Tibet China 31.6927 88.0924 0 0 0 0 0 0 ... 1 1 1 1 1 1 1 1 1 1 79 Xinjiang China 41.1129 85.2401 0 2 2 3 4 5 ... 76 76 76 76 76 76 76 76 76 76 80 Yunnan China 24.9740 101.4870 1 2 5 11 16 26 ... 180 182 182 183 184 184 184 184 184 184 81 Zhejiang China 29.1832 120.0934 10 27 43 62 104 128 ... 1255 1257 1257 1258 1260 1262 1263 1264 1265 1266

[33 rows x 82 columns] Province/State Country/Region Lat Long 1/22/20 1/23/20 1/24/20 1/25/20 1/26/20 1/27/20 ... 3/30/20 3/31/20 4/1/20 4/2/20 4/3/20 4/4/20 4/5/20 4/6/20 4/7/20 4/8/20 92 Faroe Islands Denmark 61.8926 -6.9118 0 0 0 0 0 0 ... 168 169 173 177 179 181 181 183 184 184 93 Greenland Denmark 71.7069 -42.6043 0 0 0 0 0 0 ... 10 10 10 10 10 11 11 11 11 11 94 NaN Denmark 56.2639 9.5018 0 0 0 0 0 0 ... 2577 2860 3107 3386 3757 4077 4369 4681 5071 5402

[3 rows x 82 columns] Province/State Country/Region Lat Long 1/22/20 1/23/20 1/24/20 1/25/20 1/26/20 ... 3/31/20 4/1/20 4/2/20 4/3/20 4/4/20 4/5/20 4/6/20 4/7/20 4/8/20 107 French Guiana France 3.9339 -53.1258 0 0 0 0 0 ... 43 51 51 57 61 61 72 72 77 108 French Polynesia France -17.6797 149.4068 0 0 0 0 0 ... 36 37 37 39 40 41 42 47 51 109 Guadeloupe France 16.2500 -61.5833 0 0 0 0 0 ... 114 125 128 130 134 135 135 139 141 110 Mayotte France -12.8275 45.1662 0 0 0 0 0 ... 94 94 116 128 134 147 147 171 171 111 New Caledonia France -20.9043 165.6180 0 0 0 0 0 ... 16 16 18 18 17 18 18 18 18 112 Reunion France -21.1351 55.2471 0 0 0 0 0 ... 247 281 308 321 334 344 349 358 358 113 Saint Barthelemy France 17.9000 -62.8333 0 0 0 0 0 ... 6 6 6 6 6 6 6 6 6 114 St Martin France 18.0708 -63.0501 0 0 0 0 0 ... 15 15 22 22 24 32 32 32 32 115 Martinique France 14.6415 -61.0242 0 0 0 0 0 ... 128 135 138 143 145 149 151 152 154 116 NaN France 46.2276 2.2137 0 0 2 3 3 ... 52128 56989 59105 64338 89953 92839 98010 109069 112950 259 Saint Pierre and Miquelon France 46.8852 -56.3159 0 0 0 0 0 ... 0 0 0 0 0 1 1 1 1

[11 rows x 82 columns] Province/State Country/Region Lat Long 1/22/20 1/23/20 1/24/20 1/25/20 1/26/20 ... 3/31/20 4/1/20 4/2/20 4/3/20 4/4/20 4/5/20 4/6/20 4/7/20 4/8/20 166 Aruba Netherlands 12.5186 -70.0358 0 0 0 0 0 ... 55 55 60 62 64 64 71 74 77 167 Curacao Netherlands 12.1696 -68.9900 0 0 0 0 0 ... 11 11 11 11 11 11 13 13 14 168 Sint Maarten Netherlands 18.0425 -63.0548 0 0 0 0 0 ... 6 16 18 23 23 25 37 40 40 169 NaN Netherlands 52.1326 5.2913 0 0 0 0 0 ... 12595 13614 14697 15723 16627 17851 18803 19580 20549 256 Bonaire, Sint Eustatius and Saba Netherlands 12.1784 -68.2385 0 0 0 0 0 ... 0 0 2 2 2 2 2 2 2

[5 rows x 82 columns] Province/State Country/Region Lat Long 1/22/20 1/23/20 1/24/20 1/25/20 1/26/20 ... 3/31/20 4/1/20 4/2/20 4/3/20 4/4/20 4/5/20 4/6/20 4/7/20 4/8/20 217 Bermuda United Kingdom 32.3078 -64.7505 0 0 0 0 0 ... 32 32 35 35 35 37 39 39 39 218 Cayman Islands United Kingdom 19.3133 -81.2546 0 0 0 0 0 ... 14 22 28 28 35 35 39 45 45 219 Channel Islands United Kingdom 49.3723 -2.3644 0 0 0 0 0 ... 141 172 193 232 262 309 323 335 351 220 Gibraltar United Kingdom 36.1408 -5.3536 0 0 0 0 0 ... 69 81 88 95 98 103 109 113 120 221 Isle of Man United Kingdom 54.2361 -4.5481 0 0 0 0 0 ... 60 68 95 114 126 127 139 150 158 222 Montserrat United Kingdom 16.7425 -62.1874 0 0 0 0 0 ... 5 5 5 6 6 6 6 9 9 223 NaN United Kingdom 55.3781 -3.4360 0 0 0 0 0 ... 25150 29474 33718 38168 41903 47806 51608 55242 60733 249 Anguilla United Kingdom 18.2206 -63.0686 0 0 0 0 0 ... 2 2 3 3 3 3 3 3 3 250 British Virgin Islands United Kingdom 18.4207 -64.6400 0 0 0 0 0 ... 3 3 3 3 3 3 3 3 3 251 Turks and Caicos Islands United Kingdom 21.6940 -71.7979 0 0 0 0 0 ... 5 6 5 5 5 5 8 8 8 258 Falkland Islands (Malvinas) United Kingdom -51.7963 -59.5236 0 0 0 0 0 ... 0 0 0 0 1 2 2 2 5

tommycarstensen commented 4 years ago

How come we are using the Johns Hopkins data on GitHub, when the number of cases and deaths are also in the Oxford CSV file? It seems a bit redundant.