Inserts rows of attribute values into a specified feature class or table.

The InsertCursor function returns an enumeration object that returns Row objects.


This function is superseded by arcpy.da.InsertCursor at ArcGIS 10.1 and only remains for use in legacy scripts. For improved performance, functionality, and support for newer field types and tokens, use arcpy.da.InsertCursor.


New Row objects can be obtained using the newRow method on the enumeration object into which rows are to be inserted. Each call to insertRow on the cursor creates a row in the table whose initial values are set to the values in the input row.


InsertCursor (dataset, {spatial_reference})
ParameterExplanationData Type

The feature class or table into which rows will be inserted.


Coordinates are specified in the spatial_reference provided and converted on the fly to the coordinate system of the dataset.

Return Value
Data TypeExplanation

Returns a Cursor object against a feature class or table.

Code sample

InsertCursor example

Inserts 25 new rows into a table.

import arcpy

# Create an insert cursor for a table
rows = arcpy.InsertCursor("c:/base/data.gdb/roads_lut")

# Create 25 new rows. Set the initial row ID and distance values
for x in range(1, 26):
    row = rows.newRow()
    row.setValue("rowid", x)
    row.setValue("distance", 100)

# Delete cursor and row objects to remove locks on the data
del row
del rows

Related topics