Updating Table Using API Python Library

Updating Table Using API Python Library

Hi there, 

I am attempting to add rows to an existing table using the analytics V2 BULK API and the associated python library.  

My python code is as follows: 

  1. from __future__ import with_statement
    from AnalyticsClient import AnalyticsClient
    import sys
    import json

    class Config:

    CLIENTID = "1000.XXXXX";
    CLIENTSECRET = "XXXXX";
    REFRESHTOKEN = "1000.XXXXX.XXXX";

    ORGID = "XXXXX";
    WORKSPACEID = "XXXXX";
    VIEWID = "XXXXX";

    class sample():

    ac = AnalyticsClient(Config.CLIENTID, Config.CLIENTSECRET, Config.REFRESHTOKEN)

    def import_data(self, ac):
    import_type = "append"
    file_type = "csv"
    auto_identify = "true"
    onError = "setcolumnempty"
    skipTop = 1
    thousandSeperator = 0
    dateFormt = "yyyy-MM-dd HH:mm:ss"
    columnDateFormat = {"Date":"yyyy-MM-dd HH:mm:ss"}
    file_path = "/PATH/TO/FILE/"
    bulk = ac.get_bulk_instance(Config.ORGID, Config.WORKSPACEID)
    result = bulk.import_data(Config.VIEWID, import_type, file_type, auto_identify, file_path)
    print(result)

    try:
    obj = sample()
    obj.import_data(obj.ac);

    except Exception as e:
    print(str(e))

This is taken from the sample code given in the V2 API documentation, but with correct tokens and IDs. 

When executed, I get the following error: 'sample' object has no attribute 'import_data'

I am unsure how to fix but am aware I must be doing something wrong, any ideas as to how to fix, or somewhere where I can gather more information? 

Thanks in advance, 
Sacha 

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now