How to upload to google docs

Can you guys tell me how to implement this case?
that GPTs would upload data to Google Sheets in a table by columns.

Is it possible to do it in GPTs API itself?

Hi, I don’t know if it can help you, but I managed to upload the files. I haven’t tried editing them yet. But it is possible to upload them directly to Google Drive (obviously without saving them in the shared folder on the PC)
The basic steps to take are to create a service account and project via
This allows you to have access to your cloud without having to use your login credentials, but using a surrogate. at this point you must download the JSON file of the access credentials of your “Assistant” and give it permissions as Editor of the folder or file you want to modify. After that it’s all a matter of writing code.
P.S. if you ask a gpt-4-0125-preview it will explain step by step every step to do both on the Google platform and when creating your program.

Hi, thank you.

Did you do this via GPTs ?
Or did you do it through the API Assistant ?

API Assistant. Let me start by saying that I am self-taught. So don’t judge the goodness of my code. I leave you this excerpt to give you an idea.

from googleapiclient.discovery import build
from googleapiclient.http import MediaFileUpload
from oauth2client.service_account import ServiceAccountCredentials

# Autenticazione
scope = ['']
credentials = ServiceAccountCredentials.from_json_keyfile_name('Credential_Path_Here', scope)
service = build('drive', 'v3', credentials=credentials)

# Autenticazione e setup iniziale come sopra

# Cartella ID di Google Drive dove vuoi salvare il file
folder_id = 'ID_Of_Your_Folder_Here' #You can find it in GoogleDrive

# Carica il file nella cartella specificata
file_metadata = {
    'name': 'Prova.txt', #Ovviamente ogni tipo di file va bene
    'parents': [folder_id]
media = MediaFileUpload('File_Full_Path_Here', mimetype='text/plain')
file = service.files().create(body=file_metadata, media_body=media, fields='id').execute()

print('File ID: %s' % file.get('id'))

print('File detail:', file)
1 Like