diff --git a/Scripts/Miscellaneous/Covidin Dashboard/README.md b/Scripts/Miscellaneous/Covidin Dashboard/README.md new file mode 100644 index 000000000..1b3144867 --- /dev/null +++ b/Scripts/Miscellaneous/Covidin Dashboard/README.md @@ -0,0 +1,24 @@ +# COVID19 Dashboard using Streamlit +This is app built with streamlit framework to display live covid19 data across the world with help of api.covid19api.com as data source. + +### Prerequisites +* streamlit +* requests +* pytablewriter +* datetime + +or + +`pip3 install requirements.txt` + +### How to run the script + +`streamlit run covid19.py` + +Visit Local URL: http://localhost:8501 to view the app. + +### Screenshot +![Screenshot](https://i.imgur.com/zJQhxTq.png) + +## *Author Name* +[Aravindha Hariharan M](https://aravindha1234u.github.io) diff --git a/Scripts/Miscellaneous/Covidin Dashboard/covid19.py b/Scripts/Miscellaneous/Covidin Dashboard/covid19.py new file mode 100644 index 000000000..44530c8bb --- /dev/null +++ b/Scripts/Miscellaneous/Covidin Dashboard/covid19.py @@ -0,0 +1,33 @@ +import streamlit as st +import requests +from pytablewriter import MarkdownTableWriter +from datetime import datetime + +response = requests.get('https://api.covid19api.com/summary') # Get Request to pull down data from Covid19 data source +data = response.json() + +st.markdown(MarkdownTableWriter( + table_name="Covid19 Worldwide Data", + headers=["Total Confirmed", "Total Recovered", "Total Deaths"], + value_matrix=[[data['Global']['TotalConfirmed'], data['Global']['TotalRecovered'], data['Global']['TotalDeaths']]], +)) # To form a Table for Live World data stat + +st.write("") +st.write("**Last Updated Time: {} **".format(datetime.strptime(data['Date'][:-1],"%Y-%m-%dT%H:%M:%S").strftime("%b %d %Y %H:%M:%S"))) +# To Display the date & time of Last updated data of Covid19 Reports + +st.write("") +country = st.text_input("Enter Country Name:","") # Input to filter according to country name + +table_data = [ [i['Country'],i['TotalConfirmed'],i['TotalRecovered'],i['TotalDeaths']] for i in data['Countries'] ] + +if country != "": + table_data=[] + table_data = [ [i['Country'],i['TotalConfirmed'],i['TotalRecovered'],i['TotalDeaths']] for i in data['Countries'] if i['Country'].lower() == country.lower() ] +# If country name is not entered then display all Country + +st.markdown(MarkdownTableWriter( + table_name="CountryWise Data", + headers=["Country Name", "Confirmed", "Recovered", "Deaths"], + value_matrix=table_data, +)) # table to display countrywise count reports diff --git a/Scripts/Miscellaneous/Covidin Dashboard/requirements.txt b/Scripts/Miscellaneous/Covidin Dashboard/requirements.txt new file mode 100644 index 000000000..91bb07b37 --- /dev/null +++ b/Scripts/Miscellaneous/Covidin Dashboard/requirements.txt @@ -0,0 +1,3 @@ +streamlit +requests +pytablewriter \ No newline at end of file