0
Personal talk!
Next, I needed to check if there were any updates to the Google Spreasheets shared document. I thought I’d bring this field: as a date or as a timestamp in python and check with the last saved or if the difference was less than a day, but found nothing referent in the documentation.
An example code of what I was thinking of doing:
from oauth2client.service_account import ServiceAccountCredentials
import gspread
import pandas as pd
def get_gsheet_table(url, sheet_name):
# Autenticacao com conta Google a partir de um arquivo JSON na pasta 'credentials'
scope = ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/spreadsheets"]
credentials = ServiceAccountCredentials.from_json_keyfile_name('./credentials/get_sheet_table.json', scope)
gc = gspread.authorize(credentials)
# Recebe os dados da planilha definida no paremetro
wb = gc.open_by_url(url)
sheet = wb.worksheet(sheet_name)
#TO DO: verificar se teve atualização no último dia
data = sheet.get_all_values()
df = pd.DataFrame(data)
df.columns = df.iloc[0]
df = df.iloc[1:]
return df
If the code returns that the spreadsheet has not been updated it saves processes here. I’m looking to do this way to get the document date because I wish I didn’t need to make a backup spreadsheet and compare the two.
Any other suggestion will be welcome too
After a few days with no answer on this topic, I opened a question in the American community and got a perfect user response Tanaike. He showed me that he had yes in the Google Drive Api documentation how to look at the date of file modifications through the Api Revisions: list
– Octávio Lage