AnsweredAssumed Answered

searchcursor only takes first value in field

Question asked by ccnrm on Apr 30, 2015
Latest reply on Apr 30, 2015 by ccnrm

My script ArcGIS 10.2 is using the searchcursor to read the mLanduse feature class to return the value in lField, but it is only returning the first value in lField to populate the sField in mSoils. Is my cursor2.updateRow in the wrong spot?

 

# Create a cursor on a feature class
with arcpy.da.SearchCursor(mLanduse, lField) as cursor:

# Loop through the rows and update the blank sField values in mSoils with the lField values from mLanduse
     for row in cursor:
         with arcpy.da.UpdateCursor(mSoils, sField) as cursor2:
             for row2 in cursor2:
                 if row2[0] == ' ':
                     row2[0] = row[0]
                 else:
                     row2[0] = ' '
                 cursor2.updateRow(row2)

Outcomes