Label | Explanation | Data Type |
Input Rows | The feature class, layer, table, or table view whose rows will be deleted. | Table View |
Derived Output
Label | Explanation | Data Type |
Updated Input With Rows Removed | The updated input. | Table View |
Deletes all or the selected subset of rows from the input.
The deletion of all rows or a subset of rows depends on the following:
The Input Rows parameter value can be a dBASE table, an enterprise or file geodatabase table or feature class, shapefile, layer, or table view.
If this tool is used on feature data, the entire row, including the geometry, will be deleted.
Deleting all rows from a table with a large number of rows can take time. If the intent is to delete all the rows, consider using the Truncate Table tool instead. See the Truncate Table documentation for important cautionary statements on its use.
Label | Explanation | Data Type |
Input Rows | The feature class, layer, table, or table view whose rows will be deleted. | Table View |
Label | Explanation | Data Type |
Updated Input With Rows Removed | The updated input. | Table View |
arcpy.management.DeleteRows(in_rows)
Name | Explanation | Data Type |
in_rows | The feature class, layer, table, or table view whose rows will be deleted. | Table View |
Name | Explanation | Data Type |
out_table | The updated input. | Table View |
The following Python window script demonstrates how to use the DeleteRows function in immediate mode.
import arcpy
arcpy.env.workspace = "C:/data"
arcpy.management.CopyRows("accident.dbf", "C:/output/accident2.dbf")
arcpy.management.DeleteRows("C:/output/accident2.dbf")
The following stand-alone script demonstrates how to use the DeleteRows function to delete rows based on an expression.
# 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)