cantonid = ncovdatapoint[cantonidcolumn].strip();            
            if cantonid in ["abbreviation_canton_and_fl","canton" ,"","CH","FL"]:
                continue
            name = mapidtoname[cantonid]
            try:
                if len(ncovdatapoint[1])>0:
                    d = CET.localize(datetime.datetime.strptime(ncovdatapoint[0] + " " + ncovdatapoint[1], "%Y-%m-%d %H:%M"))
                else:
                    d = CET.localize(datetime.datetime.strptime(ncovdatapoint[0] , "%Y-%m-%d"))
            except:
                print("Column 0=Date='" + ncovdatapoint[0] + "' + Column 1=Time='" + ncovdatapoint[1] +"' does not match datetime format")
            try:
                name = kantonsubst[name]
            except:
                pass
            if not (name in numcaseslookup) or d>numcaseslookup[name].timestamp:
                numcaseslookup[name] = datapoint(
                    numcases=int(ncovdatapoint[casecolumn]) if ncovdatapoint[casecolumn] != "" else 0,
                    timestamp=d,
                    sourceurl="https://github.com/openZH/covid_19/blob/master/fallzahlen_kanton_total_csv/"+filename
                    )

    return numcaseslookup

numcaseslookup = {}
for id in mapidtoname:
    numcaseslookup = { **numcaseslookup, **readNewCSV("COVID19_Fallzahlen_Kanton_" + id + "_total.csv", 2, 4) }

processGEOJSON("SWITZERLAND", "cantons.geojson", "name", lambda f: f["id"], numcaseslookup, pop)

Пример #2
0
                num = int(ncovdatapoint[4].replace(
                    ",", "")) if ncovdatapoint[4] != "" else 0
            except:
                if numstr == "1 to 4":
                    num = 2
                else:
                    raise
            try:
                d = BST.localize(
                    datetime.datetime.strptime(ncovdatapoint[0].strip(),
                                               "%Y-%m-%d"))
            except:
                print("Failed to parse timestamp '" +
                      ncovdatapoint[0].strip() + "'")
            if not name in numcaseslookup or numcaseslookup[name].timestamp < d:
                numcaseslookup[name] = datapoint(
                    numcases=num,
                    timestamp=d,
                    sourceurl="https://github.com/tomwhite/covid-19-uk-data")
            else:
                numcaseslookup[name].numcases += num
    return numcaseslookup


numcaseslookup = readNewCSV()

processGEOJSON(
    "UK",
    "Counties_and_Unitary_Authorities_April_2019_Boundaries_EW_BUC.geojson",
    "ctyua19nm", "objectid", numcaseslookup, englandpop)
Пример #3
0
            try:
                d = CET.localize(
                    datetime.datetime.strptime(ncovdatapoint[0].strip(),
                                               "%Y-%m-%d %H:%M:%S"))
            except:
                try:
                    d = CET.localize(
                        datetime.datetime.strptime(ncovdatapoint[0].strip(),
                                                   "%Y-%m-%dT%H:%M:%S"))
                except:
                    print("Failed to parse time for Italy: '" +
                          ncovdatapoint[0].strip() + "'")
                    d = datetime.datetime.now(tz=CET)
            numcaseslookup[name] = buildhelpers.datapoint(
                numcases=int(ncovdatapoint[9])
                if ncovdatapoint[9] != "" else 0,
                timestamp=d,
                sourceurl=
                "https://github.com/pcm-dpc/COVID-19/blob/master/dati-province/dpc-covid19-ita-province.csv"
            )

    return numcaseslookup


numcaseslookup = readNewCSV()

buildhelpers.processGEOJSON("ITALY",
                            "./limits_IT_provinces_simplified.geojson",
                            "prov_name", "prov_istat_code", numcaseslookup,
                            italypop)
Пример #4
0
            else:
                unambiguousname = "SK " + n
            p["GEN"] = unambiguousname
        else:
            allnames[p["GEN"]] = p["RS"]


def geojsonprop_caseskey(f, numcaseslookup):
    p = f["properties"]
    try:
        name = p["GEN"]
        try:
            if p["BEZ"] == "Landkreis" or p["BEZ"] == "Kreis":
                name2 = "LK " + name
            else:
                name2 = "SK " + name
            v = numcaseslookup.pop(name2)
            name = name2
        except:
            v = numcaseslookup.pop(name)
    except:
        name = p["GEN"]
        v = None
    return name, v


numcaseslookup = readNewCSV()
#numcaseslookup = scrapeOfficialNumbers()
processGEOJSON("GERMANY", "RKI_Corona_Landkreise.geojson", "county", "RS",
               numcaseslookup, lambda f: f["properties"]["EWZ"])
Пример #5
0
                timestamp=d,
                sourceurl="https://github.com/opencovid19-fr/data")
            if ncovdatapoint[1] == "departement":
                if v.numcases > 0 and (
                        not (name in numcasesdepartement)
                        or d > numcasesdepartement[name].timestamp
                        or v.numcases > numcasesdepartement[name].numcases):
                    numcasesdepartement[name] = v
            else:
                if v.numcases > 0 and (
                        not (name in numcasesregion)
                        or d > numcasesregion[name].timestamp
                        or v.numcases > numcasesregion[name].numcases):
                    numcasesregion[name] = v
    if False:  #len(numcasesdepartement)>0: need to do this hierarchical - use the departement data to augment the regional data
        numcaseslookup = numcasesdepartement
        francepop = departementpop
        francegeojson = departementgeojson
    else:
        numcaseslookup = numcasesregion
        francepop = regionpop
        francegeojson = regiongeojson

    return numcaseslookup, francegeojson, francepop


numcaseslookup, francegeojson, francepop = readNewCSV()

buildhelpers.processGEOJSON("FRANCE", francegeojson, "nom", "code",
                            numcaseslookup, francepop)