Sunday, September 6, 2020

Creating Pandas Dataframe from Google Drive Sheet

1. Create Service Account Key from Google Developers Console

2. Generate JSON auth key

3. Share the google sheet with the client-email id mentioned in json file.

4. Enable Google Drive API

https://console.developers.google.com/apis/api/drive.googleapis.com/overview?project=888700935625

4. Enable Google Sheets API

https://console.developers.google.com/apis/api/sheets.googleapis.com/overview?project=888700935625

GSpread Library Documentation

https://gspread.readthedocs.io/en/latest/index.html

5. Using files stored in Google Drive in Google Collab

Enable the Google Drive File Stream API

https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&scope=email%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdocs.test%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive.photos.readonly%20https%3a%2f%2fwww.googleapis.com%2fauth%2fpeopleapi.readonly&response_type=code

Reference: 

https://medium.com/@vince.shields913/reading-google-sheets-into-a-pandas-dataframe-with-gspread-and-oauth2-375b932be7bf

https://towardsdatascience.com/how-to-import-google-sheets-data-into-a-pandas-dataframe-using-googles-api-v4-2020-f50e84ea4530