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:\Users\David\DataTraker\connectors\CSVCon.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)
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.