ParseTableName (arcpy)
サマリ
Parses a table name into its components (database, owner, table) depending on the workspace. ParseTableName returns a string containing the parsed table name, with the database name, owner name, and table name separated by commas. This workspace must be a personal, file, or ArcSDE geodatabase.
構文
ParseTableName (name, {workspace})
パラメータ | 説明 | データ タイプ |
name |
Specifies which table will be parsed. | String |
workspace |
Specifies the workspace for fully qualifying the table name. The workspace must be a personal, file, or ArcSDE geodatabase. | String |
データ タイプ | 説明 |
String |
Returns the table name parsed into its components (owner name, database name, table name) separated by commas. |
コードのサンプル
ParseTableName example
Parse a table name into its components.
import arcpy
from arcpy import env
import os
# Get the full name of the feature class and
# set the workspace for parsing the name.
#
fc = arcpy.GetParameterAsText(0)
env.workspace = os.path.dirname(fc)
# Parse the feature class name into its components
#
fullName = arcpy.ParseTableName(os.path.basename(fc))
nameList = fullName.split(",")
databaseName = nameList[0]
ownerName = nameList[1]
fcName = nameList[2]
# Qualify the name of the feature class that will be appended to and set
# the workspace using the administrator's connection.
#
env.workspace = "Database Connections/Trans_admin.sde"
appendFCName = arcpy.ValidateTableName("common", "roads")
try:
if ownerName == "grace":
arcpy.CalculateField(fullName, "AppendedBy", ownerName)
arcpy.Append_management(fullName, appendFCName)
elif ownerName == "reed":
arcpy.CalculateField(fullName, "AppendedBy", ownerName)
arcpy.Append_management(fullName, appendFCName)
else:
arcpy.AddError("Unknown owner of feature class. Not appended.")
except:
arcpy.AddError(arcpy.GetMessages(2))
関連トピック
9/14/2013