Returns a valid table name for a workspace based on a table name and a workspace path. All invalid characters in the input table name are replaced with an underscore. The table name restrictions depend on the type of database.


ValidateTableName (name, {workspace})
ParameterExplanationData Type

The table name that will be validated.


The workspace that will be used to validate the table name.

If the workspace is not specified, the Current Workspace environment will be used. If the Current Workspace environment is not set, a folder workspace will be used.

Return Value
Data TypeExplanation

A valid table name for the workspace.

Code sample

ValidateTableName example

Valid table names for the workspace are returned before copying.

import os
import arcpy

# Get the input and output workspaces.
arcpy.env.workspace = arcpy.GetParameterAsText(0)
out_workspace = arcpy.GetParameterAsText(1)

# Get a list of input feature classes to be copied and copy to new output 
# location.
for fc in arcpy.ListFeatureClasses():
    out_fc = arcpy.ValidateTableName(fc, out_workspace), os.path.join(out_workspace, out_fc))

Related topics