Pygsheets和AWS Lamba [英] Pygsheets and AWS Lamba

查看:104
本文介绍了Pygsheets和AWS Lamba的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确信这里的建议是使用S3存储桶,并且我已经意识到这一点.从我收集的内容来看,我的问题要困难一点,因为我想使用python库Pygsheets写入Google表格.但是,在完成所有部署和层步骤之后...使我停滞不前的是,Pygsheets中的功能之一需要读取一个讨厌的.json文件.我确实认为它正在即时读写其他内容,这也许本身是不允许的,但我想问的是.

I am sure the suggestions here will be to use an S3 bucket and I am aware of this. My question is a bit more difficult, from what I am gathering, in that I want to use Pygsheets, a python library, to write to a Google Sheet. However, after getting through all the deployment and layer steps... what is stopping me is a pesky .json file needs to be read by one of the functions in Pygsheets. I do believe it is reading and writing something else on the fly which may not be allowed in and of itself but I am asking regardless.

直接链接到需要与Google的secret.json结合使用的功能: Pygsheets Github

Link directly to the function that needs to be used in conjunction with the secret.json from Google: Pygsheets Github

示例代码:

  print("-->Using the library pygsheets to update...")

  print(f"-->Accessing client_secret.json")
  gc = pygsheets.authorize(service_file='client_secret.json')

  print(f"-->Opening Google Sheets")
  #open the google spreadsheet 
  sh = gc.open_by_url('https://...')

  print(f"-->Accessing")
  #select the first sheet 
  wks = sh[0]

  print(f"-->Updating selected cells... ")
  #update the first sheet with df, starting at cell A11. 
  wks.set_dataframe(df, 'J14')

同样,我已经接近使用该脚本/库/lambda自动化工作表的最终产品了,我可以品尝它了:).如果绝对最佳的解决方法是S3,请保持谦虚,我是第一年尝试让我弄湿的分析师.Superior告诉我,连接到S3的连接会花费一些时间,因此这也是避免的原因.谢谢!

Again, I am close to my final product of automating my sheets using this script/library/lambda that I can taste it :). If the absolute best workaround is S3 please be gentle I am a first year analyst trying to get my feet wet. Superior is telling me it would take a while to hook up a connection to S3 so thats also a reason to avoid. Thanks!

推荐答案

已修复.只需将.json凭据添加到部署包中即可.我遇到了一个熊猫问题,所以我的.py脚本(还有,secret.json)混用了多个层和一个部署程序包.谢谢!

Fixed. Simply added the .json creds to the deployment package. I had ran into an issue with pandas so I have a blend of layers and a deployment package with my .py script (and, again, with secret.json). Thanks!

这篇关于Pygsheets和AWS Lamba的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆