InsertCursor
汇总
将属性值的行插入指定要素类或表。
InsertCursor 函数返回一个枚举对象,该对象返回 Row 对象。
旧版本:
此函数在 ArcGIS 10.1 中已被 arcpy.da.InsertCursor 取代,保留此函数仅供旧版脚本使用。 要改进性能、功能和支持更新的字段类型和令牌,请使用 arcpy.da.InsertCursor 。
讨论
可使用 newRow 方法从插入行的枚举对象获取新的 Row 对象。 光标每次调用 insertRow 都会在表中创建行,该行的初始值设置为输入行中的值。
语法
InsertCursor(dataset, {spatial_reference})
| 参数 | 说明 | 数据类型 |
|---|---|---|
|
dataset |
The feature class or table into which rows will be inserted. |
String |
|
spatial_reference |
Coordinates are specified in the |
SpatialReference |
返回值
| 数据类型 | 说明 |
|---|---|
|
Cursor |
返回针对要素类或表的 |
代码示例
InsertCursor 示例
向表中插入 25 个新行。
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)
rows.insertRow(row)
# Delete cursor and row objects to remove locks on the data
del row
del rows