The following script produces the ERROR 000210: Cannot create output... .shp and ERROR 000354: The name containts invalic characters Failed to execute (Select.).

The line with arcpy.Select_analysis is causing the problem

The result should be shapefiles with the SAME NAME as the Input, but in the Output-Workspace-Folder!

Is there a problem with the path or would you have another idea?

import arcpy, os, math
from arcpy.sa import*

pathworkspace = r"D:\aprettylongpath\InputWithShapefilesInside"
outputworkspace = r"D:\aprettylongpath\OutputStillEmpty"

arcpy.env.workspace = pathworkspace
mylist = arcpy.ListFeatureClasses()
where_clause = '"GRIDCODE" =2'

for z in mylist:
    print "Shapefile..."+z
    inShapefiles = z

The result from the print in the 3rd last line is:


2 Answers 2


I've had similar problems when writing to shapefiles where some characters in the filename causes issues (in this case the hyphen). My suggestion is to use the function to validate table names in arcpy:


Solved it by slicing my string. Don't know why the output name made a problem, but now it works.

for z in mylist:

ValidateTableName did not work for me without this change. The reason for the problem is still not known.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.