ParseTableName (arcpy)

Summary

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.

Syntax

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

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

Code Sample

ParseTableName example

Parse a table name 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.ParseTableName(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