# Import arcpy module import arcpy, sys, traceback arcpy.env.overwriteOutput = True from os import path as p arcpy.env.workspace = r"G:\ChrisGIS\PS_Steelhead\Work" try: for ws in arcpy.ListWorkspaces("*", "FileGDB"): arcpy.env.workspace = ws print '\n\nSearching in %s\n\n' %ws # # Define Variables NB = p.join(ws, 'NB') NB_out = p.join(ws, 'NB_Snapped') # # Figure out Query Statement enter here query = '"SNAP_FLAG" < \'3\'' # # Select arcpy.Select_analysis(NB, NB_out, query) print 'NB_Snapped created from %s'%NB
Solved! Go to Solution.
The help docs say that you need to always have double quotes around field names but I hardly ever do that anymore and it still works (may just be for shapefiles?). Anyways, you only need the single quotes after an operator (AND, OR, <>, = etc) if it is a text string type.
[CITY] = 'CHICAGO'
>>>> print arcpy.AddFieldDelimiters("C:\\work\\mypersonal.mdb","CITY") [CITY]
field = "CITY" cityname = "Chicago" wks = "C:/Data/MyWorkspace.mdb" where_expr = "{0} = '{1}'".format(arcpy.AddFieldDelimiters(wks,field),cityName)