Cursors are a common database structure to read (search or get), create (insert), and update (write/update) data. A cursor is a collection of rows (record from a table or features from a spatial dataset) that can be accessed and then operated on record by record where the data that is accessed for a given record can be used in other ways (in the case of writing code) for other geoprocessing tasks, queries, lists, etc.
This page covers the three cursors utilized in ArcGIS. A video exists for each type of cursor and then a separate video showing a more realistic example where two types of cursors can be used.
See the Ch 6 Demo Scripts, Data, and Jupyter Notebooks zip file to review and practice the concepts shown in these videos. This section corresponds to the Chapter 6 content in the Python Primer for ArcGIS Workbook (vol 2).
Search Cursor
A search cursor allows one to read data from a dataset and then do something with it.
In this video, the search cursor is introduced and the data accessed is simply written out. Other videos will show a more realistic script using cursors.
Insert Cursor and Creating a Geodatabase Table
An insert cursor is used to “create” new records in a dataset.
The video shows a simple example of creating a new file geodatabase table from scratch, add some fields, and then arbitrarily add 10 records (rows) to the table. This is not a real-world example, but a simple example to illustrate the insert cursor concept. The next video that shows the search and update cursor working together shows a more realistic use of cursors.
Search and Update Cursor
This video shows a more realistic use of cursors (in this case search and update) functioning together where data is read from one data set and the updated in a different data set using the data values from the data set used in the search cursor.