Qualified Field Names (Environment setting)
Tools that honor the Qualified Field Names environment will use this setting to distinguish between qualified or unqualified field names. Qualified field names are the names of fields in a feature class or table that have the name of the origin feature class or table appended onto the field name itself. This setting is relevant when working with joined data.
- The default qualified output table field naming structure is tableName.fieldName. When unqualified, the fields in the output table or feature class will always be named with the format fieldName.
- In instances where qualified field names may exceed the allowed field name width, you should set the environment to UNQUALIFIED—for example, when joining shapefiles. Shapefile fields are truncated at eight characters.
When field mappings are included in a tool's parameters, as they are in many tools in the Conversion toolbox, field names are automatically UNQUALIFIED, so there is no need to set this environment.
- Checked—The output field name will include the table name. This is the default.
- Unchecked—The output field name will not include the table name.
arcpy.env.qualifiedFieldNames = qualified_field_names
The output field name will include the table name. This can also be set using the QUALIFIED keyword. This is the default.
The output field name will not include the table name. This can also be set using the UNQUALIFIED keyword.
# Name: addjoin.py # Purpose: Join a table to a featureclass and have the output # unqualified # Author: ESRI # Import system modules import arcpy from arcpy import env try: # Set environment settings env.workspace = "C:/data" env.qualifiedFieldNames = False # Set local variables inFeatures = "Habitat_Analysis.gdb/vegtype" layerName = "veg_layer" joinTable = "vegtable.dbf" joinField = "HOLLAND95" expression = "vegtable.HABITAT = 1" outFeature = "Habitat_Analysis.gdb/vegjoin" # Create a feature layer from the vegtype featureclass arcpy.MakeFeatureLayer_management(inFeatures, layerName) # Join the feature layer to a table arcpy.AddJoin_management(layerName, joinField, joinTable, joinField) # Copy the layer to a new permanent feature class # Output fields are unqualified, so the field name will # not contain the origin table arcpy.CopyFeatures_management(layerName, outFeature) except Exception, e: # If an error occurred, print line number and error message import traceback, sys tb = sys.exc_info() print "Line %i" % tb.tb_lineno print e.message