AnsweredAssumed Answered

Not all feature classes updated with Python script

Question asked by mazizij on May 3, 2016
Latest reply on May 3, 2016 by Dan_Patterson

I am experiencing a strange issue, not all the feature classes have been updated when running the following python script in ModelBuilder

The filegeodatabase has a total of 9 feature classes (six of the feature classes have been updated and three are not), no errors are shown in ModelBuilder.

 

Capture.PNG

 

 

Here is the script I am running:

 

# Import system modules

import arcpy, os

from arcpy import env

 

#Set the workspace so that Python knows where to look for the feature classes.

# In this case, it is a GDB

arcpy.env.workspace = r'D:/spatial_data/parcel_data/scratchdb.gdb'

 

# list the feature classes

fcList = arcpy.ListFeatureClasses()

 

# loop through list

for fc in fcList:

    #check if field exists, if not, add it and calculate

     if "RegCode" not in arcpy.ListFields (fc):

          arcpy.AddField_management(fc, "RegCode", "TEXT", "", "", field_length = 8)

     if "IdCode" not in arcpy.ListFields (fc):

          arcpy.AddField_management(fc, "IdCode", "TEXT", "", "", field_length = 8)

     if "PNoCreate" not in arcpy.ListFields (fc):

          arcpy.AddField_management(fc, "PNoCreate", "TEXT", "", "", field_length = 8)

     if "PnNoCreate" not in arcpy.ListFields (fc):

          arcpy.AddField_management(fc, "PnNoCreate", "TEXT", "", "", field_length = 5)

     if "IdCreate" not in arcpy.ListFields (fc):

          arcpy.AddField_management(fc, "IdCreate", "TEXT", "", "", field_length = 21)

Outcomes