Skip to main content
added in the code snippets that were linked to the question.
Source Link
djq
  • 16.3k
  • 31
  • 112
  • 182

Check out this solution.function from by Bjorn Kuiper to test if a field exists :

def FieldExist(featureclass, fieldname):
    fieldList = arcpy.ListFields(featureclass, fieldname)

    fieldCount = len(fieldList)

    if (fieldCount == 1):
        return True
    else:
        return False

FieldExists for ArcGIS 10 Python with the following example of use:

    if (not FieldExist(myFeatureClass, "myField")):
      arcpy.AddError("Field 'myField' does not exist in " + myFeatureClass)
      sys.exit()

Check out this solution.

FieldExists for ArcGIS 10 Python

Check out this function from by Bjorn Kuiper to test if a field exists :

def FieldExist(featureclass, fieldname):
    fieldList = arcpy.ListFields(featureclass, fieldname)

    fieldCount = len(fieldList)

    if (fieldCount == 1):
        return True
    else:
        return False

with the following example of use:

    if (not FieldExist(myFeatureClass, "myField")):
      arcpy.AddError("Field 'myField' does not exist in " + myFeatureClass)
      sys.exit()
Source Link
Dana
  • 209
  • 2
  • 2

Check out this solution.

FieldExists for ArcGIS 10 Python