[英]while working with gspread-pandas module, I want to change default_dir of the module
import json
from os import path, makedirs
_default_dir = path.expanduser('~/.config/gspread_pandas')
_default_file = 'google_secret.json'
def ensure_path(pth):
if not path.exists(pth):
makedirs(pth)
hi, I'm currently working on data collection via selenium and pandas to parse the data and edit it with pandas to send the data to google spread嗨,我目前正在通过 selenium 和 pandas 进行数据收集以解析数据并使用 pandas 进行编辑以将数据发送到 google spread
however, while I'm working on gspread-pandas module, the module needs to put google_secret json file to '~/.config/gspread_pandas'.但是,当我在 gspread-pandas 模块上工作时,该模块需要将 google_secret json 文件放入“~/.config/gspread_pandas”。 which is fixed location as described in the link below https://pypi.python.org/pypi/gspread-pandas/0.15.1
这是固定位置,如以下链接中所述https://pypi.python.org/pypi/gspread-pandas/0.15.1
I want to make some function to set the custom location to achieve independent working app environment.我想制作一些功能来设置自定义位置以实现独立工作的应用程序环境。
for example, I want to locate the file to here例如,我想将文件定位到这里
default_folder = os.getcwd()
the default_folder will be where my project is located(the same folder) default_folder 将是我的项目所在的位置(同一个文件夹)
what can I do with it?我能用它做什么?
If you see the source https://github.com/aiguofer/gspread-pandas/blob/master/gspread_pandas/conf.py you can notice, that you can create your own config and pass it to Spread object constructor.如果您看到源https://github.com/aiguofer/gspread-pandas/blob/master/gspread_pandas/conf.py,您会注意到,您可以创建自己的配置并将其传递给 Spread 对象构造函数。 But yes, this part is really badly documented.
但是,是的,这部分记录确实很糟糕。
So, this code works well for me:所以,这段代码很适合我:
from gspread_pandas import Spread, conf
c = conf.get_config('[Your Path]', '[Your filename]')
spread = Spread('username', 'spreadname', config=c)
Thank you for this.这次真是万分感谢。 It really should be documented better.
它真的应该更好地记录下来。 I was getting so frustrated trying to get this to work with
heroku
, but it worked perfectly.试图让它与
heroku
一起工作,我感到非常沮丧,但它工作得很好。 I had to change to the following:我不得不更改为以下内容:
c = gspread_pandas.conf.get_config('/app/', 'google_secret.json')
spread = gspread_pandas.Spread('google_sheet_key_here_that_is_a_long_string', config=c)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.