covid19-etl/etl/stoplight.py
def parse_node(self, node):
        """
        Converts an element of an JSON file to data we can submit via Sheepdog

        Args:
            node (dict): node data

        Returns:
            (dict, dict) tuple:
                - location data, in a format ready to be submitted to Sheepdog
                - { "date1": <value>, "date2": <value> } from the row data
        """
        zipcode = node["zipcode"]
        feelings = node["feelings"]
        timestamp_created = node["timestamp_created"]
        country = node["country"]
        summary_location_submitter_id = format_location_submitter_id(country, zipcode)
        summary_location = {
            "country_region": country,
            "submitter_id": summary_location_submitter_id,
            "projects": [{"code": self.project_code}],
            "zipcode": zipcode,
        }

        date = datetime.strptime(timestamp_created, "%Y-%m-%dT%H:%M:%S").date()
        date = date.strftime("%Y-%m-%d")
        summary_clinical_submitter_id = format_summary_clinical_submitter_id(
            summary_location_submitter_id, date
        )

        summary_clinical = {
            "date": date,
            "timestamp_created": timestamp_created,
            "submitter_id": summary_clinical_submitter_id,
            "summary_locations": [{"submitter_id": summary_location_submitter_id}],
        }

        map_fields = {
            1: "feeling_healthy_count",
            2: "feeling_not_so_good_count",
            3: "feeling_sick_count",
        }

        for element in feelings:
            summary_clinical[map_fields[element["feeling"]]] = element["count"]

        return summary_location, summary_clinical

        Converts an element of an JSON file to data we can submit via Sheepdog

        Args:
            node (dict): node data

        Returns:
            (dict, dict) tuple:
                - location data, in a format ready to be submitted to Sheepdog
                - { "date1": <value>, "date2": <value> } from the row data
        
Converts an element of an JSON file to data we can submit via Sheepdog
Converts an element of an JSON file to data we can submit via Sheepdog
def parse_node(self, node):
        zipcode = node["zipcode"]
        feelings = node["feelings"]
        timestamp_created = node["timestamp_created"]
        country = node["country"]
        summary_location_submitter_id = format_location_submitter_id(country, zipcode)
        summary_location = {
            "country_region": country,
            "submitter_id": summary_location_submitter_id,
            "projects": [{"code": self.project_code}],
            "zipcode": zipcode,
        }
        date = datetime.strptime(timestamp_created, "%Y-%m-%dT%H:%M:%S").date()
        date = date.strftime("%Y-%m-%d")
        summary_clinical_submitter_id = format_summary_clinical_submitter_id(
            summary_location_submitter_id, date
        )
        summary_clinical = {
            "date": date,
            "timestamp_created": timestamp_created,
            "submitter_id": summary_clinical_submitter_id,
            "summary_locations": [{"submitter_id": summary_location_submitter_id}],
        }
        map_fields = {
            1: "feeling_healthy_count",
            2: "feeling_not_so_good_count",
            3: "feeling_sick_count",
        }
        for element in feelings:
            summary_clinical[map_fields[element["feeling"]]] = element["count"]
        return summary_location, summary_clinical
def parse_node ( self , node ) : zipcode = node [ "zipcode" ] feelings = node [ "feelings" ] timestamp_created = node [ "timestamp_created" ] country = node [ "country" ] summary_location_submitter_id = format_location_submitter_id ( country , zipcode ) summary_location = { "country_region" : country , "submitter_id" : summary_location_submitter_id , "projects" : [ { "code" : self . project_code } ] , "zipcode" : zipcode , } date = datetime . strptime ( timestamp_created , "%Y-%m-%dT%H:%M:%S" ) . date ( ) date = date . strftime ( "%Y-%m-%d" ) summary_clinical_submitter_id = format_summary_clinical_submitter_id ( summary_location_submitter_id , date ) summary_clinical = { "date" : date , "timestamp_created" : timestamp_created , "submitter_id" : summary_clinical_submitter_id , "summary_locations" : [ { "submitter_id" : summary_location_submitter_id } ] , } map_fields = { 1 : "feeling_healthy_count" , 2 : "feeling_not_so_good_count" , 3 : "feeling_sick_count" , } for element in feelings : summary_clinical [ map_fields [ element [ "feeling" ] ] ] = element [ "count" ] return summary_location , summary_clinical
Converts an element of an JSON file to data we can submit via Sheepdog
Converts an element of an JSON file to data we can submit via Sheepdog
"""
        Converts an element of an JSON file to data we can submit via Sheepdog

        Args:
            node (dict): node data

        Returns:
            (dict, dict) tuple:
                - location data, in a format ready to be submitted to Sheepdog
                - { "date1": <value>, "date2": <value> } from the row data
        """
(dict, dict) tuple:
location data, in a format ready to be submitted to Sheepdog
{ "date1": , "date2":  } from the row data
( dict dict ) tuple : location data in a format ready to be submitted to Sheepdog { " date1 " : " date2 " : } from the row data
self
node
None