ValidateTableName (arcpy)

摘要

获取表名和工作空间路径并为该工作空间返回一个有效表名。表名中出现的任何无效字符将替换为下划线“_”,以便遵循工作空间的名称限制。表名限制取决于所使用的特定 RDBMS

语法

ValidateTableName (name, {workspace})
参数说明数据类型
name

The table name to be validated.

String
workspace

The optional workspace against which to validate the table name.

If the workspace is not specified, the table name is validated using the current workspace environment. If the workspace environment has not been set, the table name is validated based on a folder workspace.

String
返回值
数据类型说明
String

工作空间的有效表名,与工作空间的名称限制相关。

代码实例

ValidateTableName 示例

返回工作空间的有效表名。

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)
    arcpy.CopyFeatures_management(
        fc, os.path.join(out_workspace, out_fc))

相关主题

5/10/2014