I would like to populate the alias names for the fields in the ACS 2014 5 year estimates file geodatabase (all 11439 of them). The ACS fgdb comes with the short_name and long_name in the metadata table. I have exported this into an excel spreadsheet, and think this would be best done using arcpy.AlterField_management() with openpyxl.


To simplify matters, I'll assume your excel spreadsheet is really a csv file with no headers and is formed like: field_name,alias:

import arcpy, csv

csvfile = "<path to file>"
FC = "<path to feature class>"    

#List of tuples
name_alias = [rows for rows in csv.reader(open(csvfile))]

errors = []
for name,alias in name_alias:
        arcpy.AlterField_management(FC, name, new_field_alias=alias)
    except Exception as e:
        errors.append(name) #Keep running list of field names that failed.

if errors:  print errors

Improving this to support Excel files should be straightforward enough.

If for whatever reason failure occurs (missing field, schema lock, improper name, etc.), the error will be printed and processing continued.

| improve this answer | |

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.