I am trying to write a loop in arcpy that will first make a selection by attribute in one feature class and then make a selection by location on another. Then I want to copy the selected features into a gdb and move to the next row in the table.
This works just fine when I use a numeric uniqueID, but I want to have the output filename retrieve a value from the attribute table (A string with the feature's name) instead of giving me "Pand + string_x" which is just a number.
This is the script:
x=1 while x < 389: string_x = str(x) x_input = "UniqueID = " + string_x x_output = r"C:\temp\BaseMap\working_data\BAG.gdb\Pand_" + string_x arcpy.SelectLayerByAttribute_management("gemeente2017","NEW_SELECTION", x_input) arcpy.SelectLayerByLocation_management("Pand","HAVE_THEIR_CENTER_IN","gemeente2017","","NEW_SELECTION","NOT_INVERT") arcpy.CopyFeatures_management("Pand",x_output, "") x += 1
I'm guessing the solution will have something to do with Field delimiters, but I'm quite new at this and have no idea how to incorporate that into my code. Using ArcGIS 10.5 and Python 2.7.12.