Covid Live Report Using Raspberry Pi

Introduction: Covid Live Report Using Raspberry Pi

As we know the whole world is being affected by COVID-19 pandemic and almost everyone is working from home. We all should utilize this duration at best, to improve our technical skills or writing some good Pythonic scripts.Let’s see a simple Python script to demonstrate the state-wise corona virus cases in India. This Python script fetches the live data from Ministry of Health Affairs Official Website.


Raspberry pi 3 b+

SD Card(min 16GB)

HDMI cable

Ethernet cable

internet connection

if you are first time in raspberry pi you need to setup it:-

other requirement

viusal stdio code(python ide) link here:-

Step 1: Raspberry Pi Setup

Make Sure the OS Is Installed on the SD Card. Your SD might have Raspberry Pi Operating System installed. ...Configure the Wifi Connection on Your SD Card. ...Turn on Your Raspberry Pi. ...Connect to Your Raspberry Pi with SSH. ...Install VNC Server. ...Install a VNC Viewer on Your Laptop.

To run a program

Before we start writing the software we first need to install the Raspberry Pi GPIO Python module. This is a library that allows us to access the GPIO port directly from Python.

To install the Python library open a terminal and execute the following

pip install python-rpi.gpio python3-rpi.gpio

With the library installed now open your favorite Python IDE and paste this code or try yourself

Step 2: You Need to Install Some Additional Features for It They Are:-

pip install bs4

pip install tabulate

pip install matplotlib

pip install numpy

you need to open command prompt, to go search button and enter cmd and open with Run as administrator

Step 3: Importing Libaray

# importing libraries

import requests

from bs4 import BeautifulSoup

from tabulate import tabulate

import os

import numpy as np

import matplotlib.pyplot as plt

Step 4: Collecting Live Data From Ministry of Health Affairs Official Website.

extract_contents = lambda row: [x.text.replace('\n', '') for x in row]

URL = '' SHORT_HEADERS = ['SNo', 'State','Indian-Confirmed', 'Foreign-Confirmed','Cured','Death']

response = requests.get(URL).content soup = BeautifulSoup(response, 'html.parser')

header = extract_contents('th'))

stats = [] all_rows = soup.find_all('tr')

for row in all_rows:

stat = extract_contents(row.find_all('td'))

if stat:

if len(stat) == 5:

# last row

stat = ['', *stat]


elif len(stat) == 6:


stats[-1][1] = "Total Cases"


Step 5: Creating Table to Show the Output

objects = []

for row in stats : objects.append(row[1])

y_pos = np.arange(len(objects))

performance = []

for row in stats :

performance.append(int(row[2]) + int(row[3]))

table = tabulate(stats, headers=SHORT_HEADERS)


Step 6: Now You Can See That Report

Remember it is live report so there is change in every time

Be the First to Share


    • Micro:bit Contest

      Micro:bit Contest
    • Halloween Contest

      Halloween Contest
    • Lamps and Lighting Contest

      Lamps and Lighting Contest