Acessando planilhas do Google pelo Python
É possível abrir e editar planilhas do Google Spreadsheets (Google Sheets, Google Planilhas) totalmente pelo Python!
Você precisa criar uma "conta especial" para que o Python consiga acessar suas planilhas. Crie ela aqui: https://console.developers.google.com/apis/api/sheets.googleapis.com
Adicione o e-mail da conta especial como editor da planilha desejada.
Gere um arquivo .json de credencial para essa conta.
import gspreadfrom oauth2client.service_account import ServiceAccountCredentials import pprint scope = ['https://spreadsheets.google.com/feeds','https://www.googleapis.com/auth/drive'] credentials = ServiceAccountCredentials.from_json_keyfile_name('C:/Users/Tito/Desktop/PythonToSpreadsheet-153760c58183.json', scope) gc = gspread.authorize(credentials) #spreadsheet = gc.open('batata') spreadsheet = gc.open_by_key('1rvXfAkAx2Y2BiG4Az-a-MtP2kHOLEr71vjavyyzsfq4') print(spreadsheet.worksheets()) sheet = spreadsheet.get_worksheet(0) all_records = sheet.get_all_records() print(all_records)
Referências
Documentação da biblioteca gspread
https://github.com/burnash/gspread
Tutorial completo usando o gspread
https://towardsdatascience.com/accessing-google-spreadsheet-data-using-python-90a5bc214fd2