What are the rules for naming valid feature classes and tables in ArcGIS Desktop, and is there any supporting document which can explain all the dataset naming limitations?
-
1Depends on what datatype you are using, eh?– Chad CooperCommented Mar 2, 2011 at 15:29
-
I am using shape file and file geodatabase– iRfAnCommented Mar 2, 2011 at 15:33
-
3something poorly documented: don't use a number for the first character of a dataset.– Kirk KuykendallCommented Mar 2, 2011 at 15:38
-
This is exactly my problem, i am trying to use number for the first character of dataset, no problem in shape file but file geodatabase is giving me error– iRfAnCommented Mar 2, 2011 at 15:43
-
Sorry, but trying to solve a similar problem: while importing in gdb, how do I add date before the name? ex: name.shp -> 120706_name feature class– Luca MoianaCommented Jul 6, 2012 at 7:58
3 Answers
It's in the documentation: Defining feature class properties
Specifically:
Names must begin with a letter, not a number or special character such as an asterisk (*) or percent sign (%). Names can't have any characters other than alphanumeric characters and underscores.
This question has been answered by Swingley above... But, in terms of automating this procedure, you could write a script that implements the IFieldChecker.ValidateTableName method. If i remember correctly it returns a corrected name with invalid characters replaced with underscores.
-
I am aware of validateTableName but here is my situation, i have shape files "1-Digit postcode.shp, 2-digit postcode.shp" and when i use validateTableName on these two shape file i will get result for both "_Digit_postcode.shp". I think i need to write my own function for this table name validation.– iRfAnCommented Mar 3, 2011 at 8:18
-
it's been a whole so correct me if i am wrong but if you use the workspace parameter, you should in fact get "_Digit_postcode.shp" and "_Digit_postcode_1.shp" Commented Mar 4, 2011 at 13:04
Since ArcGIS 10.3, there is an arcpy
function ValidateTableName
:
Takes a table name and a workspace path and returns a valid table name for the workspace. An underscore "_" will replace any invalid character found in the table name and will honor the name restrictions for the workspace. The table name restrictions depend on the specific RDBMS used.