I have a list of files that need to be present in my featureclasses - myFields. I need to add these fields if they are not present in my FeatureClasses.
import arcpy myField="Field01" myFields = [field01, field02, field03] env.workspace = "D:/test/data.gdb" fcs = arcpy.ListFeatureClasses() for f in fcs: fieldList = arcpy.ListFields(f) for field in fieldList: if field.name == myField: arcpy.AddField_management(fc, myField, "TEXT")
This works when I only have one field, but I have a list of fields! How do I adapt this when I have many fields and many different formats? Do I have to write a separate function for each field, or is there a cool python way of doing this?