covid19-etl/etl/ctp.py
def extract_races(self):
        """
        Extract race information. Store the data to a dictionary for
        fast lookup during merging process.

        """
        url = "https://docs.google.com/spreadsheets/d/e/2PACX-1vS8SzaERcKJOD_EzrtCDK1dX1zkoMochlA9iHoHg_RSw3V8bkpfk1mpw4pfL5RdtSOyx_oScsUtyXyk/pub?gid=43720681&single=true&output=csv"
        print("Getting data from {}".format(url))
        races = {}
        with closing(self.get(url, stream=True)) as r:
            f = (line.decode("utf-8") for line in r.iter_lines())
            reader = csv.reader(f, delimiter=",", quotechar='"')
            headers = next(reader)

            assert (
                headers[0] != "404: Not Found"
            ), "Unable to get file contents, received {}.".format(headers)
            assert len(headers) >= 3, "Unexpected headers: {}".format(headers)
            assert (headers[0], headers[1], headers[2]) == (
                "Date",
                "State",
                "Cases_Total",
            ), "The first 3 column names of the race data must be Dat, State, Cases_Total. Got: {}".format(
                headers
            )
            assert self.expected_race_headers.issubset(
                set(headers)
            ), "CSV headers have changed (expected {} is a subset of {}). We may need to update the ETL code".format(
                self.expected_race_headers, headers
            )

            for row in reader:
                if not row:
                    continue
                try:
                    races[(row[0], row[1], row[2])] = row[3:]
                except Exception as e:
                    print(
                        f"Error processing race row: {row}.\nSkipping row. Detail: {e}"
                    )
        return races, headers

        Extract race information. Store the data to a dictionary for
        fast lookup during merging process.

        
Extract race information. Store the data to a dictionary for
fast lookup during merging process.
Extract race information . Store the data to a dictionary for fast lookup during merging process .
def extract_races(self):
        url = "https://docs.google.com/spreadsheets/d/e/2PACX-1vS8SzaERcKJOD_EzrtCDK1dX1zkoMochlA9iHoHg_RSw3V8bkpfk1mpw4pfL5RdtSOyx_oScsUtyXyk/pub?gid=43720681&single=true&output=csv"
        print("Getting data from {}".format(url))
        races = {}
        with closing(self.get(url, stream=True)) as r:
            f = (line.decode("utf-8") for line in r.iter_lines())
            reader = csv.reader(f, delimiter=",", quotechar='"')
            headers = next(reader)
            assert (
                headers[0] != "404: Not Found"
            ), "Unable to get file contents, received {}.".format(headers)
            assert len(headers) >= 3, "Unexpected headers: {}".format(headers)
            assert (headers[0], headers[1], headers[2]) == (
                "Date",
                "State",
                "Cases_Total",
            ), "The first 3 column names of the race data must be Dat, State, Cases_Total. Got: {}".format(
                headers
            )
            assert self.expected_race_headers.issubset(
                set(headers)
            ), "CSV headers have changed (expected {} is a subset of {}). We may need to update the ETL code".format(
                self.expected_race_headers, headers
            )
            for row in reader:
                if not row:
                    continue
                try:
                    races[(row[0], row[1], row[2])] = row[3:]
                except Exception as e:
                    print(
                        f"Error processing race row: {row}.\nSkipping row. Detail: {e}"
                    )
        return races, headers
def extract_races ( self ) : url = "https://docs.google.com/spreadsheets/d/e/2PACX-1vS8SzaERcKJOD_EzrtCDK1dX1zkoMochlA9iHoHg_RSw3V8bkpfk1mpw4pfL5RdtSOyx_oScsUtyXyk/pub?gid=43720681&single=true&output=csv" print ( "Getting data from {}" . format ( url ) ) races = { } with closing ( self . get ( url , stream = True ) ) as r : f = ( line . decode ( "utf-8" ) for line in r . iter_lines ( ) ) reader = csv . reader ( f , delimiter = "," , quotechar = '"' ) headers = next ( reader ) assert ( headers [ 0 ] != "404: Not Found" ) , "Unable to get file contents, received {}." . format ( headers ) assert len ( headers ) >= 3 , "Unexpected headers: {}" . format ( headers ) assert ( headers [ 0 ] , headers [ 1 ] , headers [ 2 ] ) == ( "Date" , "State" , "Cases_Total" , ) , "The first 3 column names of the race data must be Dat, State, Cases_Total. Got: {}" . format ( headers ) assert self . expected_race_headers . issubset ( set ( headers ) ) , "CSV headers have changed (expected {} is a subset of {}). We may need to update the ETL code" . format ( self . expected_race_headers , headers ) for row in reader : if not row : continue try : races [ ( row [ 0 ] , row [ 1 ] , row [ 2 ] ) ] = row [ 3 : ] except Exception as e : print ( f"Error processing race row: {row}.\nSkipping row. Detail: {e}" ) return races , headers
Extract race information.
Extract race information .
"""
        Extract race information. Store the data to a dictionary for
        fast lookup during merging process.

        """
self