Skip to main content

A simple module to work with the RKI_COVID19.csv files issued by the Robert-Koch-Institut in Germany.

Project description

rki-covid19csv-parser

A small python module to work with the RKI_Covid19.csv files issued by the German RKI (Robert Koch Institut) on a daily basis.

Installation:

pip install rki-covid19csv-parser

Usage:

First steps:

Initialize the parser and load data from the RKI_Covid19.csv file. Because of the daily increasing file size this process can take a while.

import rki_covid19csv_parser

covid_cases = rki_covid19csv_parser.covid_cases()

covid_cases.load_rki_csv('path/to/csv')

Speeding up the loading process:

Once you have loaded the csv file it's possible to save the processed data to a file. This can speed up the process of loading the data significantly if you whish to run your script more than once.

#save file.
covid_cases.save_toFile('desired/path')

#load file.
covid_cases.load_fromFile('path/to/saved/file')

Get the covid19 data:

Supported methods:

A description of the parameters can be found below.

method description returns
cumCases(date, region_id, date_type) cumulated covid19 cases Filter object
cumDeaths(date, region_id, date_type) cumulated covid19 deaths Filter object
newCases(date, region_id, date_type) new covid19 cases Filter object
newDeaths(date, region_id, date_type) new covid19 deaths Filter object
newCasesTimespan(date, region_id, date_type, timespan) new covid19 cases in period Filter object
newDeathsTimespan(date, region_id, date_type, timespan) new covid19 deaths in period Filter object
activeCases(date, region_id, date_type, days_infectious) active covid19 cases Filter object
sevenDayCaserate(date, region_id, date_type) new covid19 cases in 7-days Filter object
sevenDayIncidence(date, region_id, date_type) new covid19 cases per 100k people in 7-days Filter object
deathRate(date, region_id, days_infectious) death rate (activeCases/newDeaths) Filter object

Parameters:

parameter type description example
date str in iso-format, datetime.date obj, datetime.datetime obj The desired date. '2020-06-01 00:00:00'
region_id str A list of region-ids can be found here. '0'
date_type str The date type to use. Meldedatum or Refdatum 'Meldedatum'
timespan int Number of last days to be included in calculation. 3
days_infectious int Number of days a case is considered as active. 14

Get your covid19 data in shape:

Each of the methods mentioned above returns an objct of the class Filter. You can use the following methods to get the data into your desired shape.

method description returns
values() raw data ndarray
by_cases(raw, decimals) absolute number of cases dict
by_age(frequency, decimals) cases sorted into agegroups dict
by_gender(frequency, decimals) cases sorted by gender dict
by_ageandgener(frequency, decimals) cases sorted by age and gender dict
parameter input type description example
frequency str weather you want the absolute or relative number of cases 'absolute'
decimals int number of decimals 3
raw bool True to get raw values True

Examples:

cases = covid_cases.cumCases(date='2021-04-29 00:00:00', region_id='01001', date_type='Meldedatum').by_gender(frequency='absolute')
print(cases)
>>> {'M': 1200, 'W': 1400, 'unbekannt': 130}

Example values!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rki-covid19csv-parser-1.2.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rki_covid19csv_parser-1.2.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file rki-covid19csv-parser-1.2.0.tar.gz.

File metadata

  • Download URL: rki-covid19csv-parser-1.2.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for rki-covid19csv-parser-1.2.0.tar.gz
Algorithm Hash digest
SHA256 11a6ac889e095ca48bc0b2f6e3707b66ad1c4d0e006639426d0aca12c828c8a8
MD5 eecc8e9c95798eddbbe5dd5928b0cc9b
BLAKE2b-256 92b2e8c1d593dd36f97bff8df78cf33edf996c9cd3185422971258fce29087a9

See more details on using hashes here.

File details

Details for the file rki_covid19csv_parser-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: rki_covid19csv_parser-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for rki_covid19csv_parser-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4daf720f2affb4bb8780a2804d848b1112e9c444c4ea3f3b6fd1bd0440f346dd
MD5 c126c6129842a2a4b958bb69e66c26b0
BLAKE2b-256 4c06c0acea3a23b3fd2f2c926f2bcb276d2f3b58d90f6273269a2b4666f9a935

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page