adding fields to attribute table

158
1
05-23-2019 01:19 PM
GregCooper
New Contributor

How would I go about making a script that adds multiple fields to an attribute table?

Tags (1)
0 Kudos
1 Reply
RandyBurton
MVP Regular Contributor

See AddField.  I usually have the field name, type, alias, and other properties in a list.  For multiple fields, I would then have a list of lists to loop through.  In a very rough form, something like:

fields = [
    ['fldName', 'TEXT', '50', 'fldAlias', .... other properties ],
    ['fldName2', 'TEXT', '50', 'fldAlias2', .... other properties ]
    ]

for fld in fields:
        arcpy.AddField_management(dbFeature,fld[0],fld[1],"#","#",
                                  fld[2],fld[3],nullable,"NON_REQUIRED", ...etc...)‍‍‍‍‍‍‍‍‍‍‍
0 Kudos