In excel you can create user defined functions with python using pyxll
. I have been moving to Google spreadsheets and using their Google app script, but the libraries are so much bigger and better in python, I wish there was a way to build user defined functions using python from Google spreadsheets. There are ways to interact python with Google sheets like gspread
. Is there a way to run python on Google app engine then get sheet to trigger that code? What other ways is there to trigger python code from Google spreadsheets?
You should create a webservice in GAE which then can be called using Google Apps Script UrlFetch
class.
This is how I usually do to integrate a third party app with Apps Script App.
In a Spreadsheet container script you can create a code like
function myFunction(){
//your code
//Call the webservice
var response = UrlFetchApp.fetch('my_webservice_url', {payload:'...', method:'POST'});
Logger.log(response.getContentText());
// your code based on response
}
Above code can be triggered by a time driven trigger in Apps Script based on some conditions
Deploy your python code as a cloud function: https://cloud.google.com/functions/docs/writing/http.
Then call your function with URL Fetch as shown above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With