【问题标题】:Import data from Zoho Analytics to Python将数据从 Zoho Analytics 导入 Python
【发布时间】:2019-10-27 10:49:21
【问题描述】:

我正在尝试通过 Zoho 客户端库连接 Zoho Analytics 和 Python:https://www.zoho.com/analytics/api/#python-library

我下载了客户端库文件,但现在不知道如何使用它。我想做的是将数据从 Zoho Analytics 导入 Python,Zoho 上的建议代码是:

from __future__ import with_statement
from ReportClient import ReportClient
import sys

from __future__ import with_statement
from ReportClient import ReportClient
import sys

class Sample:

    LOGINEMAILID="abc@zoho.com"
    AUTHTOKEN="************"
    DATABASENAME="Workspace Name"
    TABLENAME="Table Name"
    rc = None
    rc = ReportClient(self.AUTHTOKEN)

    def importData(self,rc):
        uri = rc.getURI(self.LOGINEMAILID,self.DATABASENAME,self.TABLENAME)
        try:
            with open('StoreSales.csv', 'r') as f:
            importContent = f.read()
        except Exception,e:
            print "Error Check if file StoreSales.csv exists in
                                        the current directory"
            print "(" + str(e) + ")"
            return
        impResult = rc.importData(uri,"APPEND",importContent,None)
        print "Added Rows :" +str(impResult.successRowCount) + " and Columns :"
                    + str(impResult.selectedColCount)

obj = Sample()
obj.importData(obj.rc)

如何使from ReportClient import ReportClient 工作?

另外,如果 self 没有预定义,rc = ReportClient(self.AUTHTOKEN) 如何工作?

【问题讨论】:

  • 您遇到什么错误?你提到你想让from ReportClient import ReportClient工作,但你没有说它有什么问题。
  • 您好,错误是“没有名为 ReportClient 的模块”。我应该在哪里存储客户端库文件夹?

标签: python api python-2.x zoho


【解决方案1】:

在您链接的网站上,您可以下载包含文件Zoho/ZohoReportPythonClient/com/adventnet/zoho/client/report/python/ReportClient.py 的压缩文件。我不知道为什么它嵌套得这么深,或者为什么大多数文件夹都包含一个__init__.py 文件,其中只有#$Id$

您需要提取该文件,并将其放在 Python 解释器可以找到它的位置。有关 Python 将在何处查找模块 (ReportClient.py) 的更多信息,请参阅此问题:How does python find a module file if the import statement only contains the filename?

请注意,该文件是 Python 2 代码。您需要使用 Python 2 解释器,或将其转换为 Python 3 代码。正确导入后,您可以使用他们的 API 参考开始编写代码:https://css.zohostatic.com/db/api/v7_m2/docs/python/

【讨论】:

  • 您好,谢谢您的回复。我现在会检查你的解决方案,希望能弄清楚:)
  • 这个答案对我帮助很大。只需将 ReportClient.py 放在 python lib 文件夹中即可。
猜你喜欢
  • 2021-01-10
  • 2015-03-11
  • 1970-01-01
  • 2011-10-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-30
  • 1970-01-01
相关资源
最近更新 更多