I'm looking for the most efficient method to check if & when Google Sheets have been modified using pygsheets.
My current method:
(Py):
gc = pygsheets.authorize(service_file=gServiceAccAuthFile, retries=1)
# Open spreadsheet
sh = gc.open_by_key(gSheetKey)
# Open Worksheet
wks = sh.worksheet_by_title(gWorksheetName)
# Export as CSV
wks.export(pygsheets.ExportType.CSV, path=outputDir + '/', filename=outputFileName)
(BASH):
compare_sha() {
# Compare Previous Sha to New File Sha
log_output "Original SHA: ${1}\tNew SHA: ${2}"
if [[ $1 == $2 ]]; then return 1; else return 0; fi
}
if compare_sha $origSha $newSha || [[ "$force" == '1' ]];
then ...
else ...
fi
But this feels clunky. And requires download of the full sheet (checking every 60 secs)
Is there a better method directly integrated into pygsheets or python? Is there a more efficient way in bash?
Pygsheets spreadsheet model has an updated property which will give the timestamp in wich the sheet was last updated.
updated_time = sh.updated