1

I'm trying to use this "Select" script from http://pro.arcgis.com/en/pro-app/tool-reference/analysis/select.htm#C_GUID-81DADC1A-506C-4C5F-B9F8-945132BB8DC0

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 my script:

# 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?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Dec 4, 2017 at 19:39
1
  • 1
    If it's long your query should be 'Age = 62', no quotes. It's telling you there's something it doesn't like about your in features, can you confirm the path is valid by going there in ArcCatalog (copy the path and paste into ArcCatalog folder path) and previewing the rows to ensure the data exists and isn't corrupt. Have you got C: as a "folder connection" in catalog? Commented Dec 4, 2017 at 20:45

1 Answer 1

2

If Age is an integer (long or short) field then instead of:

where_clause = '"Age" = \'62\''

use:

where_clause = "Age = 62"
  • Single quotes are only needed around 62 if that value is being stored in a text field.
  • Delimiters no longer seem to be needed around field names
  • I use double quotes around where_clause strings because that makes it easy to slip in single quotes when they are needed for text fields e.g.

    where_clause = "Type = 'X'"

answered Dec 4, 2017 at 21:37

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.