ParseFieldName

Resumen

Parses a fully qualified field name into its components (database, owner name, table name, and field name) depending on the workspace. ParseFieldName returns a string containing the parsed table name, containing the database, owner, table, and field names separated by commas. The workspace must be a personal, file, or ArcSDE geodatabase.

Sintaxis

ParseFieldName (name, {workspace})
ParámetroExplicaciónTipo de datos
name

The field name to be parsed.

String
workspace

Specifies the workspace for fully qualifying the field name. The workspace must be a personal, file, or ArcSDE geodatabase.

String
Valor de retorno
Tipo de datosExplicación
String

Returns the field name parsed into its components (owner name, database name, table name, field name) separated by commas.

Ejemplo de código

ParseFieldName example

Returns a fully qualified field name parsed into its components.

import arcpy
import os

# Get the name of the input field and parse it.
#
fieldName = arcpy.GetParameterAsText(0)
arcpy.env.workspace = os.path.dirname(fieldName)

# Create a list and populate it.
#
fullname = arcpy.ParseFieldName(os.path.basename(fieldName))
nameList = fullname.split(",")
database = nameList[0]
owner = nameList[1]
featureclass = nameList[2]

# Qualify the name of the feature class that will be appended to and set
#   the workspace using the administrator's connection.
#
arcpy.env.workspace = "Database Connections/Trans_admin.sde"
AppendFC = arcpy.ValidateTableName("common", "roads")
try:
    if owner == "grace":
        arcpy.CalculateField_management(fullname, "AppendedBy", owner)
        arcpy.Append_management(fullname, AppendFC )
    elif owner == "reed":
        arcpy.CalculateField_management(fullname, "AppendedBy", owner)
        arcpy.Append_management(fullname, AppendFC )
    else:
        arcpy.AddError("Unknown user of input feature class")
except:
    arcpy.AddError(arcpy.GetMessages(2))

Temas relacionados


7/10/2012