This question already has an answer here:
Having trouble with this python code. I keep getting a ERROR 000358: Invalid expression" code for the select layer by attribute management statement towards the end of the code. Moved the data to gdb and still couldn't get it to work...
Not exactly sure what is wrong with the syntax...any help would be great!
import arcpy, sys, os, traceback# Set workspacearcpy.env.workspace = "H:\\GIS\\PUR.mdb"plss = "Plss"comm = "Communities_sub" # Input Community feature classc_layer = "Communities_layer_sub" # Name of the Make Feature Layer output for communitiesp_layer = "Plss_layer" # Name of the Make Feature Layer outputplss_out = "Output_plss" # Name of PLSS (selected) output feature. search_distance = '0 MILES'pur_dbf = "Glenn_pur"pur_dbf_view = "Glenn_pur_view"pur_dbf_sum = "Glenn_pur_sum"comtrs_list_dbf = "Comtrs_list"try: arcpy.MakeFeatureLayer_management(plss, p_layer) arcpy.MakeFeatureLayer_management(comm, c_layer) print "Completed make feature layer management: plss, communities" arcpy.SelectLayerByLocation_management(p_layer, "WITHIN_A_DISTANCE", c_layer, search_distance, "NEW_SELECTION") print "Completed select by location on p_layer" arcpy.CopyFeatures_management(p_layer, plss_out) print "Completed copy features management for creation of plss_out" ComtrsList = [] ComtrsCursor = arcpy.SearchCursor(plss_out) for row in ComtrsCursor: ComtrsList.append(row.getValue("CO_MTRS")) print ComtrsList del ComtrsCursor, row arcpy.MakeTableView_management(pur_dbf, pur_dbf_view) print "Completed make table view for creation of pur_dbf_view" for number in ComtrsList: arcpy.SelectLayerByAttribute_management(pur_dbf_view, "NEW_SELECTION", "[COMTRS] = " + str(number)) arcpy.Statistics_analysis(pur_dbf_view, pur_dbf_sum, [["LBS_AI", "SUM"]], "CODE")except: # error code
أكثر...
Having trouble with this python code. I keep getting a ERROR 000358: Invalid expression" code for the select layer by attribute management statement towards the end of the code. Moved the data to gdb and still couldn't get it to work...
Not exactly sure what is wrong with the syntax...any help would be great!
import arcpy, sys, os, traceback# Set workspacearcpy.env.workspace = "H:\\GIS\\PUR.mdb"plss = "Plss"comm = "Communities_sub" # Input Community feature classc_layer = "Communities_layer_sub" # Name of the Make Feature Layer output for communitiesp_layer = "Plss_layer" # Name of the Make Feature Layer outputplss_out = "Output_plss" # Name of PLSS (selected) output feature. search_distance = '0 MILES'pur_dbf = "Glenn_pur"pur_dbf_view = "Glenn_pur_view"pur_dbf_sum = "Glenn_pur_sum"comtrs_list_dbf = "Comtrs_list"try: arcpy.MakeFeatureLayer_management(plss, p_layer) arcpy.MakeFeatureLayer_management(comm, c_layer) print "Completed make feature layer management: plss, communities" arcpy.SelectLayerByLocation_management(p_layer, "WITHIN_A_DISTANCE", c_layer, search_distance, "NEW_SELECTION") print "Completed select by location on p_layer" arcpy.CopyFeatures_management(p_layer, plss_out) print "Completed copy features management for creation of plss_out" ComtrsList = [] ComtrsCursor = arcpy.SearchCursor(plss_out) for row in ComtrsCursor: ComtrsList.append(row.getValue("CO_MTRS")) print ComtrsList del ComtrsCursor, row arcpy.MakeTableView_management(pur_dbf, pur_dbf_view) print "Completed make table view for creation of pur_dbf_view" for number in ComtrsList: arcpy.SelectLayerByAttribute_management(pur_dbf_view, "NEW_SELECTION", "[COMTRS] = " + str(number)) arcpy.Statistics_analysis(pur_dbf_view, pur_dbf_sum, [["LBS_AI", "SUM"]], "CODE")except: # error code
أكثر...