从Google电子表格触发Python代码? [英] Trigger python code from Google spreadsheets?
问题描述
在excel中,您可以使用 pyxll
创建用户定义的函数。我一直在使用Google电子表格并使用他们的Google应用程序脚本,但是这些库在Python中更大更好,我希望有一种方法可以使用Google电子表格中的python构建用户定义的函数。有许多方法可以与Google表单交互python,例如 gspread
。有没有办法在Google应用引擎上运行python,然后获取表单来触发该代码?还有什么其他方式可以触发Google电子表格中的Python代码?
一种方法是让一些代码读取电子表格时间,然后在条件满足时运行其他代码。
没有GAE,您可以使用以下代码:
# http://code.google.com/p/gdata-python-client/downloads/list
将gdata.spreadsheet.service导入为s
spreadsheet_key ='spreadsheetkey'#https:/ /docs.google.com/spreadsheet/ccc?key=<电子表格密钥>& usp =分享#gid = 0
worksheet_key ='od6'#first标签
gd_client = s .SpreadsheetsService(spreadsheet_key,worksheet_key)
gd_client.email ='user@gmail.com'
gd_client.password ='密码'
gd_client.ProgrammaticLogin()
list_feed = gd_client。 GetListFeed(spreadsheet_key,worksheet_key)
用于list_feed.entry中的条目:
#读取单元格值,然后在满足条件时执行某些操作
如果您希望在GAE应用程序中拥有电子表格运行代码,那么您可以发布电子表格并构建电子表格(JSON)的URL,如下所示: https://spreadsheets.google.com/feeds/list/(spreadsheetkey)/ od6 / public / values?alt = json < a> 这种方法与这两个想法:一些代码监视电子表格,当满足某些条件时,会触发其他一些代码。当条件完全来自Google Spreadsheet时,我不确定如何运行代码(在GAE应用程序中说)。 In excel you can create user defined functions with python using One way is to have some code that reads the spreadsheet all the time, then runs some other code when a condition is met. Without GAE, you could use the following code: If you wanted to have the spreadsheet run code in a GAE app, then you could publish the spreadsheet and construct the URL of the spreadsheet (JSON) like this: https://spreadsheets.google.com/feeds/list/(spreadsheetkey)/od6/public/values?alt=json
This address can be accessed via the app, the cell values can be read, and some code can be triggered. The approach is the same with both ideas: some code monitors the spreadsheet and when some condition is met, some other code is triggered. I'm not sure how you could run the code (in a GAE app, say) when the condition is met purely from the Google Spreadsheet. 这篇关于从Google电子表格触发Python代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
此地址可以通过应用程序访问,单元格值可以被读取,并且可以触发一些代码。
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?#http://code.google.com/p/gdata-python-client/downloads/list
import gdata.spreadsheet.service as s
spreadsheet_key = 'spreadsheetkey'# https://docs.google.com/spreadsheet/ccc?key=<spreadsheet key>&usp=sharing#gid=0
worksheet_key = 'od6' #first tab
gd_client = s.SpreadsheetsService(spreadsheet_key, worksheet_key)
gd_client.email = 'user@gmail.com'
gd_client.password = 'password'
gd_client.ProgrammaticLogin()
list_feed = gd_client.GetListFeed(spreadsheet_key, worksheet_key)
for entry in list_feed.entry:
#read cell values and then do something if the condition is met