You can find Previous 2 parts here →

Part 1 → Pivot Tables, Charts and reports to HTML

Part 2 → HTML to PDF and automated mails by Gmail API

Suppose every day, week or n number of times in a day, you need to fetch or download data from a source like some API link, shared drive, or maybe you are filing it manually. You are creating a report and sending to your boss.Its repetitive, boring as well as time consuming.Why don’t Automate it?

In this part, I will be explaining a periodical reporting mechanism for sending automated reports in mail.

For illustration purpose I am taking COVID19 data from below link https://api.covid19india.org/csv/latest/district_wise.csv

I recommend you to use both Jupyter Notebook and some IDE, If not available use text editor- Sublime Text3, It works with Python well.

Create two seperate files : **report.py **and scheduler.py

Can do it with IDE or use touch command on terminal

Image for post

We will work on Jupyter for simplicity first and then will move the code to .py files

Importing Libraries

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

import requests
import datetime

**Fetching the data **:

link = 'https://api.covid19india.org/csv/latest/district_wise.csv'

response = requests.get(link)
content = response.content
## Name the file as current day
file = open('covid/covid_data_'
            +str(datetime.date.today())+
            '.csv','wb')
file.write(content)
df = pd.read_csv('covid/covid_data_'+str(datetime.date.today())+'.csv')
df.head()

#covid19 #reporting #gmail-api #python #scheduling

Automated Reporting with Python (Part 3) : Scheduling, Creating
7.60 GEEK