This is really strange. I am using ArcGIS Desktop 10.3.1. I have an ArcPy script that ingests data from Excel then converts it into a pair of tables in a file GDB. One part of the code renames the fields to new names according to our field naming protocol. For some odd reason, the GDB refuses to rename some of the fields, but doesn't throw an exception or generate a message. Here is the code:

inFields = ['FieldName','FieldType','FieldLength','FieldPrecision',
xrefTbl = scratch + delim + 'SchemaFieldXwalk'

def renameFields(raw,xref,curr,wh):
incomingFields = arcpy.ListFields(raw)
incoming = []
for field in incomingFields:
    fname = field.name
with arcpy.da.SearchCursor(xref,inFields,wh) as cursor:
    for f in cursor:
        newName = f[0]
        oldName = f[6]
        domain_name = f[7]
        if newName in incoming or oldName == "FUTURE": ##Logic to test if field exists or is yet to be implemented. Added on 1/31/2017
            msg = "\t{0} field already exists or has not yet been added.".format(newName)
            msg = "{0} to be renamed to {1}.".format(oldName,newName)
            arcpy.AlterField_management(curr,oldName,newName) ##Renames fields in currWorkTable
del cursor

The fields this script refuses to rename are below with their desired end names.

MidLat ==> MIDLAT

MidLong ==> MIDLONG

Stratum ==> STRTM

Targeted ==> TARGETED



Out of 130+ fields in the table, these are the only ones that simply refuse to rename, even if we attempt it manually in the table "Properties" dialog box on the 'Fields' tab. I don't get it. Are these potentially some sort of reserved word that nobody knows about? The .format(oldName, newName) shows the correct values for those variables. The fGDB simply refuses to accept the new names.

  • Here is a list of reserved words: support.esri.com/technical-article/000010906 Though, I am not seeing any of those on there. In the 130+ fields, do they already exist? Mar 29 '17 at 19:27
  • No. Those fields shouldn't already exist. The oldName (left side of the list) are the fields that come in from the Excel file. The script looks up the oldName in the lookup table and renames it to the newName (right side of the list). These fields simply will not rename.
    – Ken Gaines
    Mar 29 '17 at 19:34
  • ArcGIS field names are case-insensitive. Do the renames which succeed have a different name, not just a different case?
    – Vince
    Mar 29 '17 at 22:35
  • You are not looking at field aliases right? And: "If the field is a required field (isRequired=true), only the field alias may be altered. "
    – BERA
    Mar 30 '17 at 5:23

Try renaming the field to something completely different first. Eg, "FieldName" -> "FieldName_OLD", then rename the field again a second time to the actual desired name. Eg, "FieldName_OLD" -> "FIELDNAME".

At present, you are renaming them to the same, just with different case. (Although there is one exception to this in your list which is a completely different name. The above may still be worth a try for that one too.)

  • In the context of the conflict, maybe "NewFieldName" should be "FIELDname"
    – Vince
    Mar 30 '17 at 3:42
  • Good point. I'll update the post. Mar 30 '17 at 4:12
  • The fields in the list above are for the cursor. The cursor loops through records in a lookup table with those fields and builds the fields accordingly. At first, we thought it might be using the aliases but after really engaging it, we discovered that the aliases have spaces and case that isn't being displayed. I think I may try the manual method outlined above and see where that takes us. I'll post up results later. Thanks for the help.
    – Ken Gaines
    Mar 30 '17 at 15:22
  • The idea of renaming them to FIELDNAME_<old> then back to the original FIELDNAME in caps worked like a champ! Thanks for that. Now to add this process to the script as a whole.
    – Ken Gaines
    Mar 30 '17 at 15:39
  • Good to hear. I reckon it should work in the script. In which case, feel free to accept this answer using the tick/checkmark button. Mar 30 '17 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.