Can you use Google Apps Script with Python?

前端 未结 6 446
北恋
北恋 2021-02-01 20:58

Google Apps Script looks to be pretty perfect for a school project, however I\'m not terribly comfortable with JavaScript and the entire rest of the project is going to be done

相关标签:
6条回答
  • 2021-02-01 21:20

    It is now possible to make requests to Google Apps Script from Python via the new Execution API, which uses a REST interface. Related blog post announcement. Learning some JS is still required.

    0 讨论(0)
  • 2021-02-01 21:22

    Never tried this but maybe you can use JSON (javascript object notation)

    In the Utilities class of Google apps script you can find the some methods (classes) that refer to this notation. jsonParse and jsonStringify https://developers.google.com/apps-script/class_utilities

    And on the other hand python has a json encoder and decoder to do the same thing on that side. http://docs.python.org/library/json.html

    There are also two tutorials which refer to these json methods for Google Apps Script developers.google.com apps-script articles picasa_google_apis (being a newby I am not allowed to put full links)

    And this as a background link
    json.org

    Than the last thing to avoid great frustrations... check out if one of these issues might be on your way to heaven.

    • Issue 1397
    • Issue 470
    • Issue 220
    • Issue 445
    0 讨论(0)
  • 2021-02-01 21:24

    So I came across this post because I also wanted to do the same thing for calculating moist air properties, which there are many free calculation tools out there, one of which is a python package. 2 days later... I'm not sure if how I interpreted this post is a complete match to my problem and solution, so I will describe briefly what I did. I've documented the detailed steps in detail in this post

    My goal was to have general access to python packages through Google Sheets via GAS, similar to how you can build custom Excel VBA macros that have extensions to many 3rd party libraries and COM interfaces. The way I implemented it was to first publish a simple WebApp fruitfarmapp on the cloud - also using Google's free trial GAE, and then make a request to this WebApp using the GAS function UrlFetchApp() and then unpack the JSON using GAS.

    A few comments

    1. Performance tip - Minimize API communication - use batch requests The way that I have it implemented now is only proof-of-concept, so I'm returning each value one-at-a-time. This wouldn't be how you wouldd do it if you need to process array of data -- for example if you have a database of sensor values of temperature and humidity. In this case you should process the response as a batch request, because the API communication is the bottleneck slow step, so you want to minimize the API fetch and do as much as you can either in the GAS or in your WebApp.

    2. General comment - this was really tedious. I would strongly recommend to try another method if at all possible. Building and deploying a WebApp just to do a simple calc is not a good use of time, especially if you are a novice like me. This took a total of 20hrs to build the WebApp from scratch, deploy it, debug various nuances, etc. The easiest part was the GAS script ~ 1 hr once the API was deployed.

    Not sure if this is helpful or not, Good luck!

    0 讨论(0)
  • 2021-02-01 21:27

    Python is amazing, and one of its most amazing qualities is being able to serve as a "glue" of sorts between different modules of a system (regardless of language).

    My suggestion is to try and make an Adapter/Wrapper around the Javascript commands you will need from Google App Script, exposing pure python functions to the rest of your program so it makes it easier on you. In the end, you will still require to learn some Javascript so... get going.

    0 讨论(0)
  • 2021-02-01 21:37

    Google Apps Scripts uses Javascript only to manipulate classes of Google products and some more general classes for doing things outside Google. Javascript is the only language.

    0 讨论(0)
  • 2021-02-01 21:40

    No, Google Apps Script is its own programming language. There are a number of APIs for individual Google Apps, but they are not as comprehensive as what is provided via Google Apps Script. They're generally focused on providing access to the data, and might be suitable if you don't need to edit it.

    0 讨论(0)
提交回复
热议问题