Collection of Python scripts to download and display Covid-19 Data from the King County Public Health team.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.4 KiB

#!/usr/bin/env python
""" Downloads and prints to stdout the latest daily
COVID-19 data from King County Washington from this site:
__author__ = "prasket"
from datetime import datetime
from openpyxl import load_workbook
import requests
import os
def download_data(save_location):
We are downloading data in excel format from the King County
Public Health Department. No api is currently available for this
data, I have been in contact with King County Data team.
Here is a working url for example:
# commenting out for now until data is updated, has been stale since 20200810
#dt_now =
#date = dt_now.strftime("%B" "-" "%d")
#url = "" + date + ".xlsx"
url = ""
if os.path.exists(save_location):
data = requests.get(url, allow_redirects=True)
open(save_location, 'wb').write(data.content)
def show_latest_data(zipcode, local_data):
wb = load_workbook(filename = local_data)
ws = wb['ZIP']
for row in ws.iter_rows(values_only=True):
if row[0] == "98121":
#zip = row[0]
population = row[1]
tests = row[2]
positives = row[4]
hospitalizations = row[6]
deaths = row[8]
print(">"*10,f"Current in {zipcode} Seattle, WA",">"*10)
print(f"Population = {population}")
print(f"Tests = {tests}")
print(f"Positives = {positives}")
print(f"Hospitilizations = {hospitalizations}")
print(f"Deaths = {deaths}")
def main():
zipcode = "98121"
local_data = "./covid-19_data.xlsx"
show_latest_data(zipcode, local_data)
if __name__ == "__main__":