Question

[Solved] Smartsheet Data Tracker: AttributeError: ‘dict’ object has no attribute ‘append’

I am new to Python and I’m working with Smartsheet Data Tracker to update a sheet from a CSV file.

I have problems about the array list management in Python; I don’t know about this error, I was reading about this error on StackOverflow but I don’t understand it:

The error:

"File "C:UsersDavidDataTrakerconnectorsCSVCon.py", line 61, in __init__     
    self.csvData.append(readerRow)
AttributeError: 'dict' object has no attribute 'append'"

And my code:

def __init__(self, sourceConfig):
    self.csvData = []


    self.csvData = {"sourceId": "siniestros",
                    "connectorClassName": "CSVCon",
                    "fileName": "siniestros.csv",
                    "isStrict": False}

    for readerRow in sourceReader:
        self.csvData.append(readerRow)
Enquirer: David

||
Solution #1:

What is going wrong is that you create a list to which you would like to append later. However you overwrite that afterwards with a dictionary, to which you cannot append. This is why you get an AttributeError.


To fix this, I would rename your dictionary (self.csvData={stuff}) that you created after your list to something else such as self.meta, perhaps. Alternatively, you could rename your list.

It doesn’t matter which, you just need to remove the naming conflict so both variables can co-exist in the namespace.

Respondent: anon582847382
Solution #2:

Actually, this was more an issue of poorly commented code in the Data Tracker project that caused the confusion in the CSVCon.py file. The CSV Configuration settings that are in those comments are an example of what should be in the settings/sources.json file.

The Configure Source section in the project documentation provides some more detail on setting up your source in the sources.json file.

There is also a section with an explanation of the CSV source specifically.

The confusing commenting has been updated to be more clear.

Respondent: stmcallister
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy