Skip to content

Instantly share code, notes, and snippets.

@cindygis
Created May 5, 2016 05:50
Show Gist options
  • Save cindygis/ced01db709f52a9be18e57793b007783 to your computer and use it in GitHub Desktop.
Save cindygis/ced01db709f52a9be18e57793b007783 to your computer and use it in GitHub Desktop.
Converts a spreadsheet containing field names and aliases into a file geodatabase table.
'''
@date 09/07/2013
@author Cindy Williams
Converts a spreadsheet containing field names and aliases
into a file geodatabase table.
'''
import arcpy
xls = r"C:\Some\Arb\Folder\test.xlsx\Fields$"
tbl = r"C:\Some\Arb\Folder\test.gdb\tbl_Samples"
with arcpy.da.SearchCursor(xls,("FIELD_NAME","ALIAS")) as cursor:
for row in cursor:
arcpy.management.AddField(tbl, row[0], "DOUBLE", field_alias=row[1])
print("Adding field {}...".format(row[0]))
print("Fields added successfully.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment