I am selecting 2 intersections from a shape file using info from a File Geodatabase Table. The values are very similar as shown in example at the bottom. I am using a LIKE in the statement but it is not returning values that should be there. It is rather lengthy but I'll try to cut it down.
Whereclausefrom = '''"FULSTRT" LIKE '%{road}%' AND "FulStrt2" LIKE '%{fromst}%\''''.format(road=roadname, fromst=fromstreet) arcpy.MakeFeatureLayer_management('IntersectionPoints', 'temp_Intersection', Whereclausefrom) Whereclauseto = '''"FULSTRT" LIKE '%{road}%' AND "FulStrt2" LIKE '%{tost}%\''''.format(road=roadname, tost=tostreet) arcpy.MakeFeatureLayer_management('IntersectionPoints', 'temp_IntersectionTo', Whereclauseto) Num1 = int(arcpy.GetCount_management("temp_Intersection").getOutput(0)) Num2 = int(arcpy.GetCount_management("temp_IntersectionTo").getOutput(0)) Num = Num1 + Num2 if Num1 < 1: Whereclausefrom2 = '''"FULSTRT" LIKE '%{fromst}%' AND "FulStrt2" LIKE '%{road}%\''''.format(road=roadname, fromst=fromstreet) arcpy.MakeFeatureLayer_management('IntersectionPoints', 'temp_Intersection', Whereclausefrom2) if Num2 < 1: Whereclauseto2 = '''"FULSTRT" LIKE '%{tost}%' AND "FulStrt2" LIKE '%{road}%\''''.format(road=roadname, tost=tostreet) arcpy.MakeFeatureLayer_management('IntersectionPoints', 'temp_IntersectionTo', Whereclauseto2) Num1 = int(arcpy.GetCount_management("temp_Intersection").getOutput(0)) Num2 = int(arcpy.GetCount_management("temp_IntersectionTo").getOutput(0)) Num = Num1 + Num2 if Num != 2: brokenRecord() brokencount = brokencount + 1 writeText("Record added to Failed Records. Next Record") else: ## rest of script if there is exactly 1 from and exactly 1 to selected
أكثر...
Whereclausefrom = '''"FULSTRT" LIKE '%{road}%' AND "FulStrt2" LIKE '%{fromst}%\''''.format(road=roadname, fromst=fromstreet) arcpy.MakeFeatureLayer_management('IntersectionPoints', 'temp_Intersection', Whereclausefrom) Whereclauseto = '''"FULSTRT" LIKE '%{road}%' AND "FulStrt2" LIKE '%{tost}%\''''.format(road=roadname, tost=tostreet) arcpy.MakeFeatureLayer_management('IntersectionPoints', 'temp_IntersectionTo', Whereclauseto) Num1 = int(arcpy.GetCount_management("temp_Intersection").getOutput(0)) Num2 = int(arcpy.GetCount_management("temp_IntersectionTo").getOutput(0)) Num = Num1 + Num2 if Num1 < 1: Whereclausefrom2 = '''"FULSTRT" LIKE '%{fromst}%' AND "FulStrt2" LIKE '%{road}%\''''.format(road=roadname, fromst=fromstreet) arcpy.MakeFeatureLayer_management('IntersectionPoints', 'temp_Intersection', Whereclausefrom2) if Num2 < 1: Whereclauseto2 = '''"FULSTRT" LIKE '%{tost}%' AND "FulStrt2" LIKE '%{road}%\''''.format(road=roadname, tost=tostreet) arcpy.MakeFeatureLayer_management('IntersectionPoints', 'temp_IntersectionTo', Whereclauseto2) Num1 = int(arcpy.GetCount_management("temp_Intersection").getOutput(0)) Num2 = int(arcpy.GetCount_management("temp_IntersectionTo").getOutput(0)) Num = Num1 + Num2 if Num != 2: brokenRecord() brokencount = brokencount + 1 writeText("Record added to Failed Records. Next Record") else: ## rest of script if there is exactly 1 from and exactly 1 to selected
أكثر...