Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Python select by attribute using a variable counter

$
0
0

I am brand new to python and trying to learn how to do some simple loops but I have hit a snag. Below is what I am working with, I am trying to select the polygon row by row, but I keep getting EOL errors and various other syntax issues as I try to troubleshoot. If I remove """ findMe """ and replace with """ "pgNum" = 1 """ it works fine. How can I change 1 to be x?

I am using the python window within ArcGIS

Thanks.

import arcpy
workSpc = (r'C:UsersadamsDownloadstmp')
smooth = 'MNR_89_Smooth'
grid = 'test_grid'
x = 1

if x == 1:
    findMe = '"pgNum" = ' + str(x)
    print findMe
    arcpy.SelectLayerByAttribute_management("test_grid","NEW_SELECTION",""" findMe """)
    x = x + 1
    print x

Viewing all articles
Browse latest Browse all 767

Trending Articles