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