Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to add data to an attribute table in ArcGIS 10 using the following code:

def make_floor_no( shapefile ):
    "Makes header for number of Floors (FLO) and calculates value"

    fieldName = "FLO"
        ARCPY.AddField_management(shapefile, fieldName, "DOUBLE")
        print "Field already there"  

    # loop through attribute table    
    Rows = ARCPY.SearchCursor( shapefile ) 

    for row in Rows:
        floors = round( row.getValue( 'HGT' ) / 3.0, 0)
        print str(floors)
        row.setValue( fieldName, floors )

However, I keep getting an error along the line

row.setValue( fieldName, floors )

I can't spot anything wrong with this, and have tried a few different options. Is there something wrong with my syntax?

The error message is as follows:

 File "Z:\", line 100, in <module> make_floor_no( InputFile )
 File "Z:\", line 71, in make_floor_no 
    row.setValue( fieldName, floors )
 File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\", line 941, in setValue
    return convertArcObjectToPythonObject(self._arc_object.SetValue(*gp_fixargs(args)))
RuntimeError: ERROR 999999: Error executing function.
share|improve this question
up vote 9 down vote accepted

Search cursors get you read-only rows objects. if you want to update you need to use the update cursor.

So change this

    Rows = ARCPY.SearchCursor( shapefile ) 

To this

    Rows = ARCPY.UpdateCursor( shapefile ) 
share|improve this answer
Thank you - that worked perfectly. – djq Dec 5 '10 at 22:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.