Exemple #1
0
        continue

    # hospitalization data
    data = sc.find(
        r'<pre id="data_1".*?> ?Datum,&quot;Normale Station&quot;,&quot;Intensivstation \(nicht beatmet\)&quot;,&quot;Intensivstation \(beatmet\)&quot;\s*([^<]+)</pre>',
        d)
    if data:
        for row in data.split(" "):
            c = row.split(',')
            if len(c) == 4:
                key, row_date = get_row_date(c[0])
                rows[key]['date'] = row_date
                if c[1] or c[2] or c[3]:
                    rows[key]['hospitalized'] = int(
                        float(c[1] or 0) + float(c[2] or 0) + float(c[3] or 0))
                rows[key]['icu'] = (sc.safeint(c[2] or 0) +
                                    sc.safeint(c[3] or 0))
                rows[key]['vent'] = c[3]
        continue

    # contact tracing data
    data = sc.find(
        r'<pre id="data_1".*?> ?Datum,&quot;Personen in Isolation&quot;,&quot;Personen in Quarantäne \(Tracing\)&quot;,&quot;Personen in Quarantäne \(Rückreise Risikoländer\)&quot;\s*([^<]+)</pre>',
        d)
    if data:
        for row in data.split(" "):
            c = row.split(',')
            if len(c) == 4:
                key, row_date = get_row_date(c[0])
                rows[key]['date'] = row_date
                rows[key]['isolated'] = sc.safeint(c[1] or 0)
Exemple #2
0
d_csv = sc.download(
    'https://data.bs.ch/explore/dataset/100073/download/?format=csv&timezone=Europe/Zurich&lang=en&use_labels_for_header=false&csv_separator=,',
    silent=True)

reader = csv.DictReader(StringIO(d_csv), delimiter=',')
is_first = True
for row in reader:
    if not row['ncumul_conf']:
        continue
    if not is_first:
        print('-' * 10)
    is_first = False
    dd = sc.DayData(canton='BS', url=row['source'])
    dd.datetime = f"{row['date']} {row['time']}"
    dd.cases = sc.safeint(row['ncumul_conf'])
    dd.new_hosp = row['new_hosp']
    dd.hospitalized = row['current_hosp']
    dd.icu = row['current_icu']
    dd.vent = row['current_vent']
    dd.recovered = row['ncumul_released']
    dd.deaths = row['ncumul_deceased']
    dd.isolated = row['current_isolated']
    dd.quarantined = row['current_quarantined']
    dd.confirmed_non_resident = row['ncumul_confirmed_non_resident']
    dd.hosp_non_resident = row['current_hosp_non_resident']
    dd.quarantine_riskareatravel = row['current_quarantined_riskareatravel']
    dd.quarantine_total = row['current_quarantined_total']
    dd.hosp_resident = row['current_hosp_resident']
    print(dd)
Exemple #3
0
                                float(c[3] or 0))
                        rows[key]['icu'] = int(
                            float(c[2] or 0) + float(c[3] or 0))
                        rows[key]['vent'] = c[3]

# order dict by key to ensure the most recent entry is last
ordered_rows = OrderedDict(sorted(rows.items()))
is_first = True
for row_date, row in ordered_rows.items():
    if not is_first:
        print('-' * 10)
    is_first = False

    dd = sc.DayData(canton='BL', url=main_url)
    dd.datetime = row['date']
    dd.cases = sc.safeint(row['cases'])
    try:
        dd.hospitalized = sc.safeint(row['hospitalized'])
    except KeyError:
        pass
    try:
        dd.icu = sc.safeint(row['icu'])
    except KeyError:
        pass
    try:
        dd.vent = sc.safeint(row['vent'])
    except KeyError:
        pass
    dd.deaths = sc.safeint(row['deaths'])
    dd.recovered = sc.safeint(row['recovered'])
    print(dd)
Exemple #4
0
    """

    d = d.replace('\n', ' ')

    # district data!
    data = sc.find(
        r'<pre id="data_1".*?> ?Datum,&quot;Bezirk Arlesheim&quot;,&quot;Bezirk Laufen&quot;,&quot;Bezirk Liestal&quot;,&quot;Bezirk Sissach&quot;,&quot;Bezirk Waldenburg&quot;\s*([^<]+)</pre>',
        d)
    if data:
        # take "Fallzahlen Bezirke BL ab Juni 2020", but not the 14d averaged one
        for row in data.split(" "):
            c = row.split(',')
            assert len(c) == 6, f"Number of fields changed, {len(c)} != 6"
            row_date = parse_row_date(c[0])
            rows[row_date]['date'] = row_date
            rows[row_date]['Arlesheim'] = sc.safeint(c[1])
            rows[row_date]['Laufen'] = sc.safeint(c[2])
            rows[row_date]['Liestal'] = sc.safeint(c[3])
            rows[row_date]['Sissach'] = sc.safeint(c[4])
            rows[row_date]['Waldenburg'] = sc.safeint(c[5])
        break

assert rows, "Couldn't find district data in iframes"

# https://www.bfs.admin.ch/bfs/de/home/statistiken/kataloge-datenbanken/karten.assetdetail.5688189.html
district_ids = {
    'Arlesheim': 1301,
    'Laufen': 1302,
    'Liestal': 1303,
    'Sissach': 1304,
    'Waldenburg': 1305,