Background
Hi All...still pretty new to python. I'm on a Mac (Sierra) running Jupyter Notebook in Firefox (87.0). I'm trying to use my python script to build a dataframe, create a new Google Sheet (a new workbook, not a new sheet in an existing workbook) on my personal Google Drive in a specific folder, and then write my dataframe to that new Google Sheet.
What I've Tried
I've been able to get my service account to open an existing Google Sheet and then later read/write using code like this:
import gspread
from oauth2client.service_account import ServiceAccountCredentials
from gspread_dataframe import set_with_dataframe
scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name(json_path, scope)
client = gspread.authorize(creds)
workbook = client.open_by_key(my_existing_google_sheet_key)
There's tons of documentation on how to read/write from existing Google Sheets, but as I said I'd like to create a new Google Sheet to write to. This has been surprisingly hard to find. The one reference I did find was this related post but can't get the OP's code to work (what is 'discovery'?). I feel like I'm missing something obvious.
Questions
- How do I use python to have my service account create a new Google Sheet on my personal Google Drive in a specific folder so that I can write to it?