AnsweredAssumed Answered

Python Problem

Question asked by lesliedb on Dec 2, 2014
Latest reply on Dec 5, 2014 by recurvata

I am trying to write a script that that changes the aliases of a table's fields, but when I ran it I got this code error:

 

ExecuteError: ERROR 001601: Failed to alter field alias.

Failed to execute (AlterField).

 

This makes no sense to me and I would love any input as to why this happened.

 

Also, here is my code that generated this error:

 

# Import geoprocessing
import arcpy


# Set workspace
arcpy.env.workspace = r'U:\newberry\new.gdb'


# Creates a list of fields from the Metadata_2010 table
fieldListTable = arcpy.ListFields("METADATA_2010")


# Creates a cursor - a data access object
rows = arcpy.SearchCursor("METADATA_2010")


# Creates an empty table to store row values
fullNames = []


# For loop thats iterates through the rows in
# the Full_Name field of the Metadata_2010 table
for row in rows:
    # Adds the row value to the fullNames list
    fullNames.append(row.getValue(fieldListTable[2].name))


# Creates a sliced list of fields from the census block group
# polygon feature class
fieldList = arcpy.ListFields("please")[2:630]


# For loop thats changes the existing alias name in the table
# to the name in the fullNames list
for i in range(len(fieldList)):
    arcpy.AlterField_management('please', str(fieldList[i].name),'',str(fullNames[i]))

Outcomes