I have a problem from combining two search cursors (one for a table and other for a feature class), there are missed records in the first table, that have not been considered by the first search cursor, I have tried many trials for error handling like join both tables and using try and except syntax, but all of that have not worked, also after reading answers on previous questions here, I have tried (cursor.reset() function), but it gives no end for the script. here you are the part of my code:
cursor3= arcpy.da.SearchCursor(table1, [field1, field2])
for row in cursor3:
try:
cursor4= arcpy.da.SearchCursor(FeatureClass1, ['OBJECTID'])
for row1 in cursor4:
try:
if row1[0] == row[0] or row1[0] == row[1]:
FeatureClass2= arcpy.env.workspace+"\\FeatureClass2"
where = "\"%s\" = %i OR \"%s\" = %i" % ('OBJECTID', row[0],'OBJECTID',row[1])
arcpy.Select_analysis(FeatureClass1, FeatureClass2, where)
# Local variables:
FeatureClass2 = "FeatureClass2"
FeatureClass2_Intersect = "FeatureClass2_Intersect"
# Process: Intersect
arcpy.Intersect_analysis(FeatureClass2, FeatureClass2_Intersect, "ALL", "", "LINE")
arcpy.AddField_management(FeatureClass2_Intersect,'Value',"DOUBLE")
cursor2= arcpy.da.UpdateCursor(FeatureClass2_Intersect, 'Value')
for row2 in cursor2:
try:
if row2[0] ==6:
row2= cursor2.next()
if row2[0] ==7:
row2[1]=float(42)
cursor2.updateRow(row2)# give a value to value field
except:
del cursor2
except:
row1= cursor4.next()
except:
row= cursor3.next()
del cursor3