I was able to get the following python code to work so the alias names within the feature class are persistent in the geo-database.
Outline of process:
�?� Create an arcpy fields mapping object and add the feature class fields using FieldMappings
�?� Create a python list which has the field and alias name.
�?� Export the arcpy fields mapping object to a text string using exportToString
�?� Loop through the fields and alias names list and use the python string replace function to replace the field name with the alias name within the fields mapping exported string.
NOTE: the alias name is the doubled quoted word after the field name.
Python scripting:
v_fieldmappings = arcpy.FieldMappings()
v_fieldmappings.removeAll()
v_fieldmappings.addTable(v_input_fc)
v_field_alias_list = [['OBSID', 'Observation ID'], ['SPPCODE', 'Species Code'],
['COMNAME', 'Common Name'], ['SCINAME', 'Scientific Name'],
['FEDSTAT', 'Federal Status Code'], ['FEDERAL_STATUS', 'Federal Status Desc'],
['STATESTAT', 'State Status Code'], ['STATE_STATUS', 'State Status Desc']]
v_fieldmappingsstring = str(v_fieldmappings.exportToString())
for v_field in v_field_alias_list:
v_field_name = str(v_field[0])
v_alias_field = str(v_field[1])
if v_fieldmappingsstring.find(v_field_name) >= 0:
v_fieldmappingsstring = v_fieldmappingsstring.replace('"' + v_field_name + '"', '"' + v_alias_field + '"')
else:
print "Field name " + v_field_name +"not found. Not setting alias name."
v_fieldmappings.loadFromString(v_fieldmappingsstring)
Then the v_fieldmappings can be used in a feature class to feature class process.