Exemple #1
0
import logging
import os
from datetime import datetime

import pandas as pd

from country_codes import get_county_code
from utils import sha1sum, write_timestamp_file, download_nijz_xslx_file

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__file__)

covid_data_path = os.getenv('COVID_DATA_PATH')
assert covid_data_path, 'COVID_DATA_PATH env variable must be set. (The location of the COVID-DATA folder)'

download_nijz_xslx_file(download_folder=os.path.join(covid_data_path, 'EPI'),
                        search_for='tedenski_prikaz_okuzeni')
download_nijz_xslx_file(download_folder=os.path.join(covid_data_path, 'EPI'),
                        search_for='tedenski_prikaz_umrli')

SOURCE_FILE_INFECTED = max(
    glob.glob(
        os.path.join(covid_data_path, 'EPI') +
        '/tedenski_prikaz_okuzeni*.xlsx'))  # take latest
logger.info(f'SOURCE_FILE okuzeni: {SOURCE_FILE_INFECTED}')
SOURCE_FILE_DECEASED = max(
    glob.glob(
        os.path.join(covid_data_path, 'EPI') +
        '/tedenski_prikaz_umrli*.xlsx'))  # take latest
logger.info(f'SOURCE_FILE umrli: {SOURCE_FILE_DECEASED}')
CSV_FOLDER = os.path.join(os.path.dirname(__file__), '../csv')
Exemple #2
0
import logging
import os
from datetime import datetime, timedelta

import pandas as pd

from utils import sha1sum, write_timestamp_file, download_nijz_xslx_file


logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__file__)

covid_data_path = os.getenv('COVID_DATA_PATH')
assert covid_data_path, 'COVID_DATA_PATH env variable must be set. (The location of the COVID-DATA folder)'

download_nijz_xslx_file(download_folder=os.path.join(covid_data_path, 'EPI'), search_for='dnevni_prikazi')

SOURCE_FILE = max(glob.glob(os.path.join(covid_data_path, 'EPI') + '/dnevni_prikazi*.xlsx'))  # take latest
logger.info(f'SOURCE_FILE: {SOURCE_FILE}')
CSV_FOLDER = os.path.join(os.path.dirname(__file__), '../csv')


def export_dataframe_to_csv(name: str, dataframe):
    filename = os.path.join(CSV_FOLDER, f'{name}.csv')
    old_hash = sha1sum(filename)
    dataframe.replace({0: None}).astype('Int64').to_csv(filename, line_terminator='\r\n')
    write_timestamp_file(filename=filename, old_hash=old_hash)


municipalities = {}
with open(file=os.path.join(CSV_FOLDER, 'dict-municipality.csv'), encoding='utf-8') as f: