Select to view content in your preferred language

Error regarding row.getValue(): 'function' object has no attribute "xxx"

728
5
08-19-2011 06:58 AM
AbbyFlory
Deactivated User
OS: Windows 7, 64-bit
IDE: PyScripter
ArcGIS: 10.0 - Concurrent Use license accessed remotely

Hi,
I am receiving the following error when trying to run a basic while-loop over feature class rows:  'function' object has no attribute "getValue".  My code is:

import arcpy
from arcpy import env
env.workspace = "C:/***/TestScripts_UsingNHL"
env.overwriteOutput = True

inTable = "C:/***/Bbuffers.shp"
inField = "CITY_TOWN"
rows = arcpy.SearchCursor(inTable)
row = rows.next

while row:
    City = row.getValue(inField)  #Error thrown here
    row = rows.next()

print "Finished!"

The field "CITY_TOWN" does exist, and it is spelled correctly.  I get the same error even if I try to print instead of getValue: print row.CITY_TOWN.  This seems basic, but I cannot find a fix.  Any help/suggestions would be appreciated.  Thanks!
Tags (2)
0 Kudos
5 Replies
HemingZhu
Frequent Contributor
OS: Windows 7, 64-bit
IDE: PyScripter
ArcGIS: 10.0 - Concurrent Use license accessed remotely

Hi,
I am receiving the following error when trying to run a basic while-loop over feature class rows:  'function' object has no attribute "getValue".  My code is:

import arcpy
from arcpy import env
env.workspace = "C:/***/TestScripts_UsingNHL"
env.overwriteOutput = True

inTable = "C:/***/Bbuffers.shp"
inField = "CITY_TOWN"
rows = arcpy.SearchCursor(inTable)
row = rows.next

while row:
    City = row.getValue(inField)  #Error thrown here
    row = rows.next()

print "Finished!"

The field "CITY_TOWN" does exist, and it is spelled correctly.  I get the same error even if I try to print instead of getValue: print row.CITY_TOWN.  This seems basic, but I cannot find a fix.  Any help/suggestions would be appreciated.  Thanks!


City =row.CITY_TOWN
0 Kudos
AbbyFlory
Deactivated User
...didn't work.  Any other thoughts?
0 Kudos
BruceNielsen
Frequent Contributor
You did leave out the parenthesis on the first row=rows.next()<--missing
0 Kudos
AbbyFlory
Deactivated User
Yes!  Thanks!
0 Kudos
DanPatterson_Retired
MVP Emeritus
Things changed in version 10, try:

inTable = "C:/***/Bbuffers.shp"
 inField = "CITY_TOWN"
 rows = arcpy.SearchCursor(inTable)
 #row = rows.next
 
for row in rows:
  City = row.getValue(inField) #Error thrown here
  #row = rows.next()
 


see
cursors  http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000001q000000.htm
getValue etc.  http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v000000nv000000.htm
0 Kudos