Inserting rows with InsertCursor
You can insert a row into a table or feature class using an InsertCursor
object. If you want to insert attribute values along with the new row, you'll need to supply the values in the order found in the attribute table.
Getting ready
The InsertCursor()
function is used to create an InsertCursor
object that allows you to programmatically add new records to feature classes and tables. The insertRow()
method on the InsertCursor
object adds the row. A row in the form of a list or tuple is passed into the insertRow()
method. The values in the list must correspond to the field values defined when the InsertCursor
object was created. Similar to instances that include other types of cursors, you can also limit the field names returned using the second parameter of the method. This function supports geometry tokens as well.
The following code example illustrates how you can use InsertCursor
to insert new rows into a feature class. Here, we insert two new wildfire points...