Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

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

$
0
0

I keep getting the following error:

Traceback (most recent call last):
File “R:GIS_ScriptsandToolsPullHotParametersLabel.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?


Viewing all articles
Browse latest Browse all 767

Trending Articles