ParseFieldName (arcpy)

Summary

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.

Syntax

ParseFieldName (name, {workspace})
ParameterExplanationData Type
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
Return Value
Data TypeExplanation
String

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

Code Sample

ParseFieldName example

Returns a fully qualified field name parsed into its components.

import arcpy

# Get the name of the input field and parse it.
#
field_name = arcpy.GetParameterAsText(0)
workspace = arcpy.GetParameterAsText(0)

# Create a list and populate it.
#
fullname = arcpy.ParseFieldName(field_name, workspace)
database, owner, featureclass = fullname.split(",")

# 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"
append_fc = arcpy.ValidateTableName("common", "roads")

try:
    if owner in ["ted", "laura"]:
        arcpy.CalculateField_management(
            fullname, "AppendedBy", owner, "PYTHON_9.3")
        arcpy.Append_management(fullname, append_fc)
    else:
        arcpy.AddError("Unknown user of input feature class")
except arcpy.ExecuteError:
    arcpy.AddError(arcpy.GetMessages(2))

Related Topics

6/21/2013