arcpy.management.DeleteRows(in_rows)
|
名称
|
说明
|
数据类型
|
|
in_rows
|
各行将被删除的要素类、图层、表或表视图。
|
Table View
|
派生输出
|
名称
|
说明
|
数据类型
|
|
out_table
|
更新的输入。
|
Table View
|
代码示例
DeleteRows 示例 1(Python 窗口)
以下 Python 窗口脚本演示了如何在即时模式下使用 DeleteRows 函数。
import arcpy
arcpy.env.workspace = "C:/data"
arcpy.management.CopyRows("accident.dbf", "C:/output/accident2.dbf")
arcpy.management.DeleteRows("C:/output/accident2.dbf")
以下独立脚本演示了如何使用 DeleteRows 函数基于表达式删除行。
# Description: Delete rows from a table based on an expression
# Import system modules
import arcpy
# Set environment settings
arcpy.env.workspace = "C:/data"
# Set local variables
inTable = "accident.dbf"
outTable = "C:/output/new_accident.dbf"
tempTableView = "accidentTableView"
expression = arcpy.AddFieldDelimiters(tempTableView, "Measure") + " = 0"
# Run CopyRows to make a new copy of the table
arcpy.management.CopyRows(inTable, outTable)
# Run MakeTableView
arcpy.management.MakeTableView(outTable, tempTableView)
# Run SelectLayerByAttribute to determine which rows to delete
arcpy.management.SelectLayerByAttribute(tempTableView, "NEW_SELECTION",
expression)
# Run GetCount and if some features have been selected, run
# DeleteRows to remove the selected rows.
if int(arcpy.management.GetCount(tempTableView)[0]) > 0:
arcpy.management.DeleteRows(tempTableView)