HOW TO
In ArcGIS Pro, the Fields toolset contains tools to create and modify fields for any geodatabase table or feature class. These modifications can be made by running a Python script in ArcGIS Pro and this article provides the workflow.
The image below shows the Schools_all attribute table with field aliases containing underscores and lower case letters.
import arcgis import os
arcpy.env.overwriteOutput = True
<variableName> = arcpy.ListFields('<layerName>')
print("Changing the field alias to field name by Capitalizing the initial letter") for field in <variableName>: if not field.required: arcpy.management.AlterField('<layerName>', field.name, field.name, field.name.rstrip(field.name[-2:])) arcpy.management.AlterField('<layerName>', field.name, field.name, field.name.replace("_"," ").title()) print("Completed")
The following code block demonstrates the full working script.
import arcpy import os arcpy.env.overwriteOutput=True infeature=arcpy.GetParameterAsText(0) fields=arcpy.ListFields('Schools_all') print("Changing the field alias to field name by Capitalizing the initial letter") for field in fields: if not field.required: arcpy.management.AlterField('Schools_all', field.name, field.name,field.name.rstrip(field.name[-2:])) arcpy.management.AlterField('Schools_all', field.name, field.name, field.name.replace("_"," ").title()) print("Completed")
The image below shows the updated field aliases using Python in ArcGIS Pro.
Article ID: 000029252
Get help from ArcGIS experts
Download the Esri Support App