Created
October 10, 2019 20:58
-
-
Save mhweber/d3aa0ba0b7619ad553d7b4aead7cb316 to your computer and use it in GitHub Desktop.
Pass a variable to an arcpy selection query statement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os, arcpy, sys | |
| shp = 'F:/shapefile.shp' | |
| arcpy.MakeFeatureLayer_management(shp,"lyr") | |
| rows = arcpy.SearchCursor("lyr") | |
| for row in rows: | |
| name=str(row.getValue("ColumnName")) | |
| arcpy.SelectLayerByAttribute_management("lyr", "NEW_SELECTION", "'ColumnName' = '%s'"%name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment