A feature class that I'm using as an input to a script was clipped from an enterprise SDE geodatabase, and has all of its field names in lower case. The script I'm using references all the field names in uppercase, as the input was previously clipped from a normal geodatabase instead.
Rather than update every line of the script that references a given field name (the script has about 1000 lines total). I came up with what I thought was a way to change the field names of the input clipped feature class to upper case- my code was as following:
"""def capitalize_sde():
input = "INPUT"
fl = []
flist = arcpy.ListFields(input)
for f in flist:
if f.name != "Shape_Area" and f.name != "Shape_Length":
if f.type != "GEOMETRY" and f.type != "OID" and f.type != "BLOB":
fl.append(f.name)
for lowerfl in fl:
upperfl = lowerfl.upper()
arcpy.AlterField_management(input, lowerfl, upperfl)
capitalize_sde()
"""
I thought this would work to change all the field names of my "INPUT" feature class to upper case. Instead, the field names stayed the same, all in lower case letters. When I tested this in the debug console of vs code, it showed that the upper() function worked to my string variable upperfl, but the last line- arcpy.AlterField_management() didn't actually update the field.
If you know of any way to fix this problem, I'd greatly appreciate it!
Thanks for any help!