I'm using a pretty simple python script to pull in a Google Sheet (that I don't have write access to) with the requests
library, and write out a csv file, modifying the headers to what my CMS (Wordpress) needs for to update some data.
I don't want to re-export the file unless it's the Google Sheet modified since the last time I ran the script.
It looks like using the Python Google API library is one option, but maybe more than is necessary for this task.
The GSpread package looks promising, but the
worksheet.updated
attribute, which it looks like back in 2015 would have held a datetime string seems to be currently non-functional
This :
>>> import gspread
>>> from oauth2client.service_account import ServiceAccountCredentials
>>> scope = ['https://spreadsheets.google.com/feeds']
>>> creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
>>> client = gspread.authorize(creds)
>>> file_id = '1rYQ84SIKTFUOTl1xyFkHMNLt9CW3tOMFbOelOvVwx1k'
>>> url = "https://docs.google.com/spreadsheets/d/{0}".format(file_id)
>>> doc = client.open_by_url(url)
>>> sheet = doc.get_worksheet(0)
>>> sheet.updated
>>>
My original thought was save a copy of the non-modified imported csv and compare the any new imports to that before creating my new export file. Maybe that's a simple enough solution as it's only a few hundred lines of data.
Any recommendations?