Is it true that it is not possible to directly connect a Google Apps Script (which uses JavaScript) to a Google Sheets spreadsheet using Python?
I am asking this more as a design question: would it not be possible to keep a Google Apps Script in a file and simply use Python to connect it to a gsheets spreadsheet using the spreadsheet id? I have not found a way to do this, but it would be interesting to hear if anyone has found a way to do it and if so how.
CodePudding user response:
I am not sure if this answer is on topic, but I think it might be what you trying to do... That is, push an apps script file up to Google...
I believe you can accomplish this task via the Apps Script Python API:
https://developers.google.com/apps-script/api/quickstart/python
My company does not give the the creds to use the API, so, I can't give you the step by step on this one...
hth,
David
CodePudding user response:
To be fair, I really don't think this is the right approach. Might depend on what you're doing... If you have a Python script that is writing Google Apps Script and needs to push it to Google, you might look in these docs
https://developers.google.com/apps-script/api/reference/rest
If that's not what you're doing and you're trying to manipulate a Spreadsheet by using Python to run some Google Apps Script, refer to the same link. There is "REST Resource: v1.scripts" which has a "run" method.
Last, if your end goal is to manipulate some Google Sheet--you can probably get away with using a Python library like described in this link
https://developers.google.com/sheets/api/quickstart/python
Because just about anything you can use Google Apps Script for, you can technically also do in Python. Except, with Python you have Python and the entire compendium of Python libraries at your disposal. The Google Sheet is ultimately just a data store and reading and writing to it are the things you're trying to do with it--be it Google Apps Script or Python as the driver.
Otherwise, you might be able to use Python to manipulate CLASP