[GIS] ArcGIS 10.1 arcpy Update Cursor is returning a list instead of a row

arcgis-10.1arcpycursor

I keep getting the following error:

Traceback (most recent call last):
File "R:\GIS_ScriptsandTools\PullHotParametersLabel.py", line 16, in

TitleLine = ""+row.getValue(IDfield)+" ("+ row.getValue(Datefield)+")
"

AttributeError: 'list' object has no attribute 'getValue'

When I am trying to run a typical for row in cursor loop when working with an UpdateCursor.
For the life of me, I can't figure out why it thinks the row is a list and not a row object.
Here is my script:

import arcpy
SourceTable = arcpy.GetParameterAsText(0)
IDfield = arcpy.GetParameterAsText(1)
Datefield =arcpy.GetParameterAsText(2)
SelectedParams = arcpy.GetParameterAsText(3)
OutputField = arcpy.GetParameterAsText(4)
SelectedFields = SelectedParams.split(';')
AllFields = arcpy.ListFields(SourceTable)

FieldDict = {}
for field in AllFields:
    FieldDict[field.name]=field.aliasName

with arcpy.da.UpdateCursor(SourceTable,"*") as cursor:
    for row in cursor:     
        TitleLine = "<und><bol>"+row.getValue(IDfield)+" </bol>("+ row.getValue(Datefield)+")</und>"
        LabelList = [TitleLine]
        for Field in SelectedFields:
            if row.getvalue(Field) <>0:
                Alias = FieldDict.get(Field)
                ParamValue = row.getValue(Field)
                ParamLine = '{0} = {1:,}'.format(Alias,ParamValue)
                LabelList.append(ParamLine)
        if len(LabelList)<2:
            LabelList.append("All &lt; 2L")
        Label = '\n'.join(LabelList)
        row[OutputField] = Label
        cursor.updateRow(row)    
del row, cursor

Does anybody have any ideas where I'm screwing up on this?

Best Answer

You're using an arcpy.da.UpdateCursor. It by definition and design returns rows as lists, not as row objects. You need to use an arcpy.UpdateCursor if you want row objects.

The old arcpy objects from 10.0 like arcpy.*Cursor are still there in 10.1 and still behave as expected. You can even use the old 9.3 arcgisscripting APIs and they'll still work the same. You don't need to "upgrade" your scripts to use the new APIs if they already work.

Related Question