AnsweredAssumed Answered

SelectByAttribute Problem

Question asked by JonUGIS17 on Aug 10, 2017
Latest reply on Aug 11, 2017 by xander_bakker

Hi, I am trying to write a script that selects a parcel number and writes it to a PDF. I am having trouble with the SelectLayerByAttribute tool.  I am writing the script in PyCharm not in the Python Window of ArcMap. This is what I have gathered from various sources online.  I am pretty sure its an issue with my syntax. Any help would be much appreciated.  This is what I have so far.

 

import arcpy

mxd = arcpy.mapping.MapDocument(
r"//bondserv2/USERS-COUNTY/ahuber/Desktop/Bond.mxd")

parcel =
"Parcel_Point"

df = arcpy.mapping.ListDataFrames(mxd, parcel)

layer = arcpy.mapping.ListLayers(mxd
, "", df)

arcpy.SelectLayerByAttribute_management(layer
, "NEW_SELECTION", "[PIN] = '021101104001'")

I run the SelectLayerByAttribute tool in the python window just like the above code and it works. But trying to get it working in the PyCharm IDE is being a real pain. I'm new to python and arcpy, this is my first attempt at automating some one my everyday tasks.

Outcomes