AnsweredAssumed Answered

Loop exits after 100 count while creating domains using python

Question asked by kauskuma424 on Mar 23, 2015

Hello all,

 

I am trying to create domains on feature class or table class by reading a table which holds all look up information. Following is example code for what I am doing:

 

tableIndex = tableClasses.index("LookupTable")
tableGnLookup = tableClasses[tableIndex]

with arcpy.da.SearchCursor(tableGnLookup, 
                           ["DATA_TABLE", "DATA_REF", "LOOKUP_TABLE", "LOOKUP_REF", "LOOKUP_DESCRIPTION"], 
                           where_clause="DATA_TABLE IS NOT NULL AND LOOKUP_TABLE IS NOT NULL", 
                           sql_clause=["", "ORDER BY LOOKUP_TABLE, DATA_TABLE"])  as cursor:
    
    # Itrate each row
    for row in cursor:

        # Get row values
        dataTableName = str(row[0])
        dataRefField = str(row[1])
        lookupTableName = str(row[2])
        lookupRefField = str(row[3])
        lookupDescriptionField = str(row[4])

        # Find table in all tables
        try:
            tableIndex = tableClasses.index(lookupTableName)
        except:
            tableIndex = -1

        # Get table if table index is found
        if tableIndex >= 0:
            lookupTable = tableClasses[tableIndex]
            arcpy.TableToDomain_management(lookupTable, lookupRefField, lookupDescriptionField, database, lookupTableName, lookupTableName)

        # Find feature class in feature class list
        try:
            tableIndex = featureClasses.index(dataTableName)
        except:
            tableIndex = -1

        # Get feature class at found index
        if tableIndex >= 0:
            fc = featureClasses[tableIndex]
            try:
                arcpy.RemoveDomainFromField_management(fc, dataRefField)
            except Exception as e:
                print e.message

            try:
                # Assign domain to field
                arcpy.AssignDomainToField_management(fc, dataRefField, domainName)

            except Exception as e:
                print e.message

 

This function works fine for 100 loops but exits after that without any error or warnings. I tried to iterate loop by just printing output which give me ~500 rows. Could anyone please help me to identify the problem here?

 

Thanks in advance!!

Outcomes