Sunday, November 17, 2024
Google search engine
HomeLanguagesPython – Retrieve latest Covid-19 World Data using COVID19Py library

Python – Retrieve latest Covid-19 World Data using COVID19Py library

COVID19Py Library retrieves the latest data revolving around the Covid-19 pandemic. This Covid-19 World Dataset is hosted at the John Hopkins University servers. 

To install the library, execute below command in your system command line:

pip install COVID19Py 

The library provides the following methods:

  • getAll(): Retrieve the entire dataset as a JSON
  • getLatest(): Get the latest stats of confirmed cases, recoveries and deaths
  • getLocations(): Get the locations where Covid-19 cases exist
  • getLatestChanges(): Look for any changes since you last retrieved the data

Below example illustrate the above methods:

Example:

Python3




# import given package
import COVID19Py
  
# Create an object,
# specify data source as JHU Servers
covid = COVID19Py.COVID19(data_source = "jhu")
  
# Retrieve all Data
# in the form of json
data = covid.getAll()
  
# Enormous Data will be returned
print("Data", data) 
  
# Get the latest data
latest = covid.getLatest()
print("Latest Data", latest)
  
# Get Locations where covid cases exist
# Can be Ranked by 'confirmed' cases,
# number of 'deaths' or
# number of 'recovered' patients
locations = covid.getLocations(timelines = True,
                               rank_by = 'confirmed')
print("Locations", locations) 
  
# Check for any changes since
# data was last retrieved
changes = covid.getLatestChanges()
  
# Printing changes, if any
print("Changes since last visit", changes)


Output:

Data: Enormous data returned in the json form; this screenshot represents just the first few lines of the data.

Country-wise Covid Data in the Json form

Country-wise Covid Data in the form of nested dictionaries

Latest Data: Latest numbers related to Covid19 (Globally)

Global Covid19 Numbers

Global Covid19 Numbers

Location Data: Enormous location-wise Covid Data will be return in json form.This screenshot represents the first few lines.

Location Data

Location Data

Changes since Last Visit: Currently all 0.

Changes since last visit

Changes since last visit

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments