Пример #1
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import scrape_common as sc
from scrape_fr_common import get_fr_xls

xls_url, xls = get_fr_xls()
rows = sc.parse_xls(xls,
                    header_row=0,
                    sheet_name='tests COVID19',
                    enable_float=True)

for row in rows:
    td = sc.TestData(canton='FR', url=xls_url)
    td.week = sc.find(r'S (\d+)', row['Semaine'])
    td.year = '2020'
    tot = int(row['Total Testing Pop FR'])
    pos = int(row['Total POS Pop FR'])
    td.positive_tests = pos
    td.total_tests = tot
    print(td)
Пример #2
0
    for i in range(len(weeks)):
        district = tds[0].string
        if district in inhabitants:
            dd = sc.DistrictData(canton='FR', district=district)
            dd.url = url
            dd.week = weeks[i]
            # TODO restore once all weeks are in 2021
            # dd.year = '20' + year
            dd.year = years[i]
            dd.new_cases = tds[i + 1].string
            dd.population = inhabitants[district]
            dd.district_id = district_ids[district]
            print(dd)


# daily data from xls
xls_url, xls, main_url = get_fr_xls()
rows = sc.parse_xls(xls, header_row=0)
for row in rows:
    row_date = row.search(r'.*Date.*')
    for district, d_id in district_ids.items():
        district_cell = row.search(r'.*' + district + '.*')
        dd = sc.DistrictData(canton='FR', district=district)
        dd.url = url
        dd.date = row_date.date().isoformat()
        dd.new_cases = district_cell
        dd.population = inhabitants[district]
        dd.district_id = d_id
        print(dd)