行の削除(Delete Rows) (Data Management)
サマリ
すべての行または選択した行のサブセットを入力行から削除します。
入力行がフィーチャクラスまたはテーブルの場合は、すべての行が削除されます。入力行がレイヤまたはテーブル ビューの場合は、レイヤ内の選択した行のみが削除されます。
使用法
-
入力行には、INFO テーブルまたは dBASE テーブル、ArcSDE、ファイル、あるいはパーソナル ジオデータベース テーブルまたはフィーチャクラス、シェープファイル、レイヤ、またはテーブル ビューを指定できます。
-
入力行に選択がない場合は、すべての行が削除されます。
-
このツールをフィーチャ データで使用する場合は、ジオメトリを含む行全体が削除されます。
構文
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