Created
November 5, 2021 21:42
-
-
Save Ray-Mangan/36b59db1d8c42b3262ee29d0bfa1b1df to your computer and use it in GitHub Desktop.
Rename fields in a GDB feature class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#path to feature class | |
dataset = r"\\some\directory.gdb\feature_class" | |
#store new field names and new field aliases in a dictionary | |
#key is current field name, value is new field name | |
rename_fields = { | |
"current_name1":"new_name1", | |
"current_name2":"new_name2" | |
} | |
#rename the fields | |
for key, value in rename_fields.items(): | |
print("renaming {0} to {1}".format(key,value)) | |
arcpy.AlterField_management(dataset,field=key, new_field_name=value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment