Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cunla/gsheets-report
Generate a graph report from google sheets and send it in email
https://github.com/cunla/gsheets-report
Last synced: 13 days ago
JSON representation
Generate a graph report from google sheets and send it in email
- Host: GitHub
- URL: https://github.com/cunla/gsheets-report
- Owner: cunla
- License: mit
- Created: 2020-01-05T14:06:36.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-15T15:12:34.000Z (over 1 year ago)
- Last Synced: 2024-05-02T00:02:11.692Z (7 months ago)
- Language: Python
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Google spreadsheet email reporter
=================================
This is used to read data from a google spreadsheet, generate a graph from the spreadsheet,
and send it as an email report.
# Installation
* Create a virtualenv for the project, python3 is required
```
virtualenv env -p `which python3`
```
* Activate the virtualenv from the project dir for working in terminal
```
$ source env/bin/activate
```
(Setup the the project interpreter in PyCharm)* Install the project requirements by running
```
$ pip3 install -r requirements.txt
```
* Create the file `secrets.py`, it should have gmail user and app specific password.
In order to obtain app specific password, go to [accounts.google.com](accounts.google.com)
and under **Security** go to **App passwords**
```python
SMTP_SERVER_USER = "[email protected]"
SMTP_SERVER_PASSWORD = "xxx" # Generate app specific code if you have 2FA
```
alternatively, you can add these to `settings.py`
* Enable google spreadsheet api at [https://developers.google.com/sheets/api/quickstart/python](https://developers.google.com/sheets/api/quickstart/python)
Download the client configuration and save `credentials.json` in the same dir
with the project.# Usage
Edit `settings.py` to match your required needs
```python
# Import from secrets.py
# SMTP_SERVER_USER = "xxx"
# SMTP_SERVER_PASSWORD = "xxx"from secrets import *
# Google spreadsheet data
SPREADSHEET_ID = '1jMlzxtYrmd'
SPREADSHEET_RANGE = 'Weight!A:C'# Number of months to include in the report
NUMBER_OF_MONTHS = 6# SMTP server settings, username and password are stored in secrets.py
SMTP_SERVER = "smtp.gmail.com"
SMTP_SERVER_PORT = 465# Report sender name and email address
REPORT_SENDER = ("full name", "[email protected]")
# Report email subject
REPORT_SUBJECT = 'Report'
# Report recipient name and email address
REPORT_RECIPIENT = ("b", "[email protected]")# Report template
REPORT_TEMPLATE = 'templates/weight_report.html'
```Afterwards, run
```
$ python main.py
```To run periodically, you can use cron, edit your crontab and add the following:
```
# Run every first of the month
0 0 1 * * ~/projects/gsheets-report/run.sh
```### Tech
* pandas
* jinja2
* google spreadsheets api### Development
* You can edit the template being sent under `templates/report.html`# Next steps
* Beautify graph generated by pandas# Troubleshooting
### Getting `CERTIFICATE_VERIFY_FAILED` error
Your SSL certificates were not installed as part of python.
Run `tools/install_certificates.py` to install them.