I need help setting up an if-than-else within a if-else statement. I need the code i need to check if selected features has any text inside the AddressID field if it does have any text inside the field i need it to by pass the with arcpy.da.SearchCursor and the with arcpy.da.UpdateCursor and move on to the next process. if doesn't have any text inside the field i need it to preform the with arcpy.da.SearchCursor and the with arcpy.da.UpdateCursor. I would appreciate any help.
import arcpy, os from arcpy import env env.workspace = r"C:\temp\python\test.gdb" arcpy.env.qualifiedFieldNames = False arcpy.env.overwriteOutput = True BldSelection = "BuildingFootprints" Bld = arcpy.env.workspace + os.sep + "BuildingFootprints" #target point feature class BldCount = int(arcpy.GetCount_management(Bld).getOutput(0)) dsc = arcpy.Describe(BldSelection) selection_set = dsc.FIDSet if len(selection_set) == 0: print "There are no features selected" elif BldCount >= 1: #Gets the highest AddressID and calculates new point to assign new highest AddressID Bld_list = [] with arcpy.da.SearchCursor(Bld, ["Bld_ID"]) as cursor: for row in cursor: try: if "Bld" in row[0]: Bld_list.append(int(row[0].strip("Bld"))) except TypeError: pass del cursor print Bld_list Bld_list.sort() Bld_ID = Bld_list[-1] + 1 with arcpy.da.UpdateCursor(BldSelection, "Bld_ID") as rows: for row in rows: row[0] = 'Bld' + str(Bld_ID) Bld_ID += 1 rows.updateRow(row) del row del rows