2019 December 10thCreating a new Google Sheet in Colab using the Drive APIapi, google colab
Title is self-explanatory.
Code snippet below:
from google.colab import auth
auth.authenticate_user()
from googleapiclient.discovery import build
drive_service = build('drive', 'v3')
# creating our gsheet
file_metadata = {
'name': output_file_name,
'parents': "insert id here",
'mimeType': 'application/vnd.google-apps.spreadsheet',
}
res = drive_service.files().create(body=file_metadata).execute()
print(res)
# storing the id of our newly created gsheet
# will allow us to write into it using gspread for example
gsheet_id = res['id']