covid19-etl/etl/stoplight.py
def parse_file(self, url):
        """
        Converts a json file to data we can submit via Sheepdog. Stores the
        records to submit in `self.location_data` and `self.time_series_data`.
        Ignores any records that are already in Sheepdog (relies on unique
        `submitter_id` to check)

        Args:
            url (str): URL at which the file is available
        """
        print("Getting data from {}".format(url))
        with closing(self.get(url, stream=True)) as r:
            data = r.json()
            timestamp_created = data["data"]["generated"]
            country = data["country_code"]
            summary_location_list = []
            try:
                for zipcode, feelings in data["data"]["submissions"].items():
                    node = {
                        "zipcode": zipcode,
                        "feelings": feelings,
                        "timestamp_created": timestamp_created,
                        "country": country,
                    }
                    summary_location, summary_clinical = self.parse_node(node)
                    summary_location_submitter_id = summary_location["submitter_id"]
                    if summary_location_submitter_id not in summary_location_list:
                        self.summary_locations.append(summary_location)
                        summary_location_list.append(summary_location_submitter_id)
                    self.summary_clinicals.append(summary_clinical)
            except ValueError as e:
                print(f"ERROR: value error. Detail {e}")

        Converts a json file to data we can submit via Sheepdog. Stores the
        records to submit in `self.location_data` and `self.time_series_data`.
        Ignores any records that are already in Sheepdog (relies on unique
        `submitter_id` to check)

        Args:
            url (str): URL at which the file is available
        
Converts a json file to data we can submit via Sheepdog.
Converts a json file to data we can submit via Sheepdog .
def parse_file(self, url):
        print("Getting data from {}".format(url))
        with closing(self.get(url, stream=True)) as r:
            data = r.json()
            timestamp_created = data["data"]["generated"]
            country = data["country_code"]
            summary_location_list = []
            try:
                for zipcode, feelings in data["data"]["submissions"].items():
                    node = {
                        "zipcode": zipcode,
                        "feelings": feelings,
                        "timestamp_created": timestamp_created,
                        "country": country,
                    }
                    summary_location, summary_clinical = self.parse_node(node)
                    summary_location_submitter_id = summary_location["submitter_id"]
                    if summary_location_submitter_id not in summary_location_list:
                        self.summary_locations.append(summary_location)
                        summary_location_list.append(summary_location_submitter_id)
                    self.summary_clinicals.append(summary_clinical)
            except ValueError as e:
                print(f"ERROR: value error. Detail {e}")
def parse_file ( self , url ) : print ( "Getting data from {}" . format ( url ) ) with closing ( self . get ( url , stream = True ) ) as r : data = r . json ( ) timestamp_created = data [ "data" ] [ "generated" ] country = data [ "country_code" ] summary_location_list = [ ] try : for zipcode , feelings in data [ "data" ] [ "submissions" ] . items ( ) : node = { "zipcode" : zipcode , "feelings" : feelings , "timestamp_created" : timestamp_created , "country" : country , } summary_location , summary_clinical = self . parse_node ( node ) summary_location_submitter_id = summary_location [ "submitter_id" ] if summary_location_submitter_id not in summary_location_list : self . summary_locations . append ( summary_location ) summary_location_list . append ( summary_location_submitter_id ) self . summary_clinicals . append ( summary_clinical ) except ValueError as e : print ( f"ERROR: value error. Detail {e}" )
Converts a json file to data we can submit via Sheepdog.
Converts a json file to data we can submit via Sheepdog .
"""
        Converts a json file to data we can submit via Sheepdog. Stores the
        records to submit in `self.location_data` and `self.time_series_data`.
        Ignores any records that are already in Sheepdog (relies on unique
        `submitter_id` to check)

        Args:
            url (str): URL at which the file is available
        """
self
url
URL at which the file is available
URL at which the file is available