I'm trying to write a function that takes in a feature class and converts all its field names to uppercase, using the Alter Field tool. Here is my code:
def capitalize_fc_fnames(in_fc):
# capitalizes all field names for specified feature class
print("\nCapitalizing all field names for master network output feature class..")
all_fields = [f.name for f in arcpy.ListFields(in_fc)]
for f in all_fields:
arcpy.management.AlterField(in_fc, f, new_field_name=f.upper())
I am running the function on a feature class in a file geodatabase. The function runs without errors, but when I open the feature class, none of the fields have been altered.
I have also tested in Pro using the Alter Field GUI tool on just one field, but with that nothing happens: no errors, no changes to the field names.
This post from 2017 suggests that at that time it was a known but unresolved bug that Alter Field did nothing. I *really* hope that's not still the case as I have 90+ fields I want to convert to uppercase. @BrandonFlessner did you ever find a solution to this? @DanPatterson do you have any sage input on this?
Thanks,