covid19-etl/etl/jhu_to_s3.py
def nested_dict_to_data_by_time(self):
        """
        See `nested_dict_to_geojson` docstring for details on the aggregation.
        """
        print("Generating {}...".format(IL_JSON_BY_TIME_FILENAME))
        countyList = {}
        for country_data in self.nested_dict.values():

            # for US only
            if country_data["country_region"] != "US":
                continue

            for province_data in country_data.get("provinces", {}).values():

                # for IL only
                if province_data["province_state"] != "Illinois":
                    continue

                for county_data in province_data.get("counties", {}).values():
                    county_fips = county_data["fips"]

                    countyList[county_fips] = {
                        "county": county_data["county"],
                        "by_date": {},
                    }
                    # add county-level time_series data for IL counties
                    for date, ts in county_data["time_series"].items():
                        confirmed = ts.get("confirmed", 0)
                        deaths = ts.get("deaths", 0)

                        countyList[county_fips]["by_date"][date] = {
                            "C": replace_small_counts_simple(confirmed),
                            "D": replace_small_counts_simple(deaths),
                        }

        with open(
            os.path.join(CURRENT_DIR, MAP_DATA_FOLDER, IL_JSON_BY_TIME_FILENAME), "w"
        ) as f:
            # create smaller file size by eliminating white space
            f.write(
                json.dumps(
                    {"il_county_list": countyList, "last_updated": self.latest_date},
                    separators=(",", ":"),
                )
            )

        See `nested_dict_to_geojson` docstring for details on the aggregation.
        
See `nested_dict_to_geojson` docstring for details on the aggregation.
See ` nested_dict_to_geojson ` docstring for details on the aggregation .
def nested_dict_to_data_by_time(self):
        print("Generating {}...".format(IL_JSON_BY_TIME_FILENAME))
        countyList = {}
        for country_data in self.nested_dict.values():
            if country_data["country_region"] != "US":
                continue
            for province_data in country_data.get("provinces", {}).values():
                if province_data["province_state"] != "Illinois":
                    continue
                for county_data in province_data.get("counties", {}).values():
                    county_fips = county_data["fips"]
                    countyList[county_fips] = {
                        "county": county_data["county"],
                        "by_date": {},
                    }
                    for date, ts in county_data["time_series"].items():
                        confirmed = ts.get("confirmed", 0)
                        deaths = ts.get("deaths", 0)
                        countyList[county_fips]["by_date"][date] = {
                            "C": replace_small_counts_simple(confirmed),
                            "D": replace_small_counts_simple(deaths),
                        }
        with open(
            os.path.join(CURRENT_DIR, MAP_DATA_FOLDER, IL_JSON_BY_TIME_FILENAME), "w"
        ) as f:
            f.write(
                json.dumps(
                    {"il_county_list": countyList, "last_updated": self.latest_date},
                    separators=(",", ":"),
                )
            )
def nested_dict_to_data_by_time ( self ) : print ( "Generating {}..." . format ( IL_JSON_BY_TIME_FILENAME ) ) countyList = { } for country_data in self . nested_dict . values ( ) : if country_data [ "country_region" ] != "US" : continue for province_data in country_data . get ( "provinces" , { } ) . values ( ) : if province_data [ "province_state" ] != "Illinois" : continue for county_data in province_data . get ( "counties" , { } ) . values ( ) : county_fips = county_data [ "fips" ] countyList [ county_fips ] = { "county" : county_data [ "county" ] , "by_date" : { } , } for date , ts in county_data [ "time_series" ] . items ( ) : confirmed = ts . get ( "confirmed" , 0 ) deaths = ts . get ( "deaths" , 0 ) countyList [ county_fips ] [ "by_date" ] [ date ] = { "C" : replace_small_counts_simple ( confirmed ) , "D" : replace_small_counts_simple ( deaths ) , } with open ( os . path . join ( CURRENT_DIR , MAP_DATA_FOLDER , IL_JSON_BY_TIME_FILENAME ) , "w" ) as f : f . write ( json . dumps ( { "il_county_list" : countyList , "last_updated" : self . latest_date } , separators = ( "," , ":" ) , ) )
See `nested_dict_to_geojson` docstring for details on the aggregation.
See ` nested_dict_to_geojson ` docstring for details on the aggregation .
"""
        See `nested_dict_to_geojson` docstring for details on the aggregation.
        """ # for US only # for IL only # add county-level time_series data for IL counties # create smaller file size by eliminating white space
self