1

According the ArcGIS 10.2.2 help this should work:

inZoneData = sys.argv[1] # This is a shapefile
fieldList = arcpy.ListFields(inZoneData) 
    for field in fieldList:
        if field.name.upper() == 'STATUS':  # rename status
            arcpy.AlterField_management(inZoneData, field, 'status')

but it does not. What I get is invalid parameter. If I try this:

for field in arcpy.ListFields(inZoneData):
    if field.name() == 'STATUS':  # rename status
        arcpy.AlterField_management(inZoneData, 'STATUS', 'status')

I get invalid unicode error. I understand that error at least.

Can anyone shine some light on how AlterField actually works?

I've tried several other things but cannot get this tool working.

Is it a shapefile bug?

3

This is not a bug because, as @Paul and @Branco, have said the Alter Field (Data Management) tool documents its scope as (with my bolding):

This tool provides the ability to rename fields or rename field aliases for any geodatabase table or feature class.

If you want to do the same to a shapefile I suggest copying your shapefile into a file geodatabase (or an in_memory workspace) feature class, perform the Alter Field there, and then copy the feature class back to a shapefile.

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.