删除行 (Data Management)

摘要

从“输入行”中删除所有行或所选行子集。

如果“输入行”来自要素类,则会删除所有行。如果输入行来自图层表视图,则只会删除图层中选定的行。

用法

语法

DeleteRows_management (in_rows)
参数说明数据类型
in_rows

各行将被删除的要素类、图层、表或表视图。

Table View

代码示例

DeleteRows 示例(Python 窗口)

以下 Python 窗口脚本演示了如何在立即模式下使用 DeleteRows 功能。

 import arcpy from arcpy import env  env.workspace = "C:/data" arcpy.CopyRows_management("accident.dbf", "C:/output/accident2.dbf") arcpy.DeleteRows_management("C:/output/accident2.dbf")
DeleteRows 示例 2(独立脚本)

以下独立脚本演示了如何使用 DeleteRows 功能基于表达式删除行。

# Name: DeleteRows_Example2.py # Description: Delete rows from a table based on an expression # Author: ESRI   # Import system modules import arcpy from arcpy import env  try:      # Set environment settings     env.workspace = "C:/data"       # Set local variables     inTable = "accident.dbf"     outTable = "C:/output/new_accident.dbf"     tempTableView = "accidentTableView"     expression = arcpy.AddFieldDelimiters(tempTableView, "Measure") + " = 0"       # Execute CopyRows to make a new copy of the table     arcpy.CopyRows_management(inTable, outTable)       # Execute MakeTableView     arcpy.MakeTableView_management(outTable, tempTableView)       # Execute SelectLayerByAttribute to determine which rows to delete     arcpy.SelectLayerByAttribute_management(tempTableView, "NEW_SELECTION", expression)       # Execute GetCount and if some features have been selected, then execute     #  DeleteRows to remove the selected rows.     if arcpy.GetCount_managemnt(tempLayer) > 0:         arcpy.DeleteRows_management(tempLayer)           except Exception, e:     # If an error occurred, print line number and error message     import traceback, sys     tb = sys.exc_info()[2]     print "Line %i" % tb.tb_lineno     print e.message

环境

相关主题

许可信息

ArcView: 是
ArcEditor: 是
ArcInfo: 是

7/10/2012