I am trying to remove rows from a feature class that is included in a python tool in ArcGIS 10.7. I have run the code as an independent Python script and it runs fine, but when I run the following code, I get an error. tmpfile
is a copy of an existing feature that is in a geodatabase.
tmpfile = os.path.basename(tempfile.TemporaryFile().name)
arcpy.CopyFeatures_management(infile, tmpfile)
### remove unnecessary values
vals = ["Unknown",""]
for val in vals:
query = """ "DATEDISC" = '%s' """ %val
tmpfile = arcpy.SelectLayerByAttribute_management(tmpfile,"NEW_SELECTION", query)
arcpy.DeleteRows_management(tmpfile)
In the standalone script, this removes any rows with the values of "Unknown" or "". In the tool, I receive the error message for arcpy.SelectLayerByAttribute_management() that
The value cannot be a feature class
ERROR 000840: The value is not a Raster Layer.
ERROR 000840: The value is not a Mosaic Layer.
Failed to execute (SelectLayerByAttribute).
This seems like odd behavior for this function.
Does anyone know why this would be happening?
tmpfile
is. How are you setting tmpfile or passing it into your tool?