I'm trying to use this "Select" script from https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fpro.arcgis.com%2Fen%2Fpro-app%2Ftool-...
but it keeps giving me the following error.
Traceback (most recent call last):
File "<string>", line 10, in <module>
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\analysis.py", line 91, in Select
raise e
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\analysis.py", line 88, in Select
retval = convertArcObjectToPythonObject(gp.Select_analysis(*gp_fixargs((in_features, out_feature_class, where_clause), True)))
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 506, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.ERROR 000732: Input Features: Dataset C:\arcGIS_Shared\Python\PythonTestScript.gdb\CAPatients does not exist or is not supportedFailed to execute (Select).
And Here is the script I'm using:
# Import system modules
import arcpy
# Set local variables
in_features = r"C:\arcGIS_Shared\Python\PythonTestScript.gdb\CAPatients"
out_feature_class = r"C:\arcGIS_Shared\Python\PythonTestScript.gdb\Geocoded2"
where_clause = '"Age" = \'62\''
# Execute Select
arcpy.Select_analysis(in_features, out_feature_class, where_clause)
In the script above, the datatype for "Age" is "long"; but I have also tried replacing "Age" with "Zip_Code", which is "text".
Anyone have any ideas what I'm doing wrong or missing?
Solved! Go to Solution.
A table can originate from many sources... some of which don't have geometry, that is why I ask
From the help... so it is a table from a featureclass or a feature layer then...
Extracts features from an input feature class or input feature layer,
for tables http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/table-select.htm
it is a featureclass (your link doesn't work) and not some other type of data type?
Also your query, are the values in the field text or numeric?
where_clause = '"Age" = \'62\''
print(where_clause)
"Age" = '62'
where_clause = '"Age" = 62'
print(where_clause)
"Age" = 62
The trail bracket was included in the hyper link. It just went to the help page for the Select_analysis tool:
The datatype for "Age" is "long"; but I have also tried replacing "Age" with "Zip_Code", which is "text".
And "CAPatients" is a table in my geodatabase. Not sure if that answers your question or not.
Is it a featureclass ... ie is the table being queried just a table? or a featureclass table... they are not the same
I would almost venture to say that it is an actual table. It would work with either the feature layer or feature class. If it were an actual feature class the error shouldn't have thrown that last line.
C:\arcGIS_Shared\Python\PythonTestScript.gdb\CAPatients does not exist or is not supportedFailed to execute (Select).
A table can originate from many sources... some of which don't have geometry, that is why I ask
From the help... so it is a table from a featureclass or a feature layer then...
Extracts features from an input feature class or input feature layer,
for tables http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/table-select.htm
Table Select fixed the problem. Thank you everyone for your help!
Two things. First, since I can't see the whole code, I presume you have set your arcpy.env.workspace to something?
Second, I ran into a very similar issue with that same tool yesterday actually. I spent a ton of time having to dig through SQL formatting for that where clause.
temp = arcpy.Select_analysis("All.shp", "NEW_SELECTION", "ReportingU = '{0}'".format(i)) arcpy.CopyFeatures_management(temp, '{0}.shp'.format(i))
The "i" is just iterating through a list of unit IDs which are strings. But that is the format for the where clause that worked for me with that tool.