Hi,
I have a Feature Class to Feature Class script that is supposed to take a Feature Class (FC) of locations and create a separate FC for each location. However, it keeps giving me the following two errors.
ERROR 000210: Cannot create output E:\arcGIS_Shared\Business Analyst\PotentialCitePackages.gdb\NorthEdmond
ERROR 000354: The name contains invalid characters
Failed to execute (FeatureClassToFeatureClass)
Here is the FC to FC script:
inFeatures = "PythonTest_Geocoded"
fields = ['ObjectID', 'Shape','USER_Center']
with arcpy.da.SearchCursor(inFeatures, fields) as cursor:
for row in cursor:
outLocation = r"E:\arcGIS_Shared\Business Analyst\PotentialCitePackages.gdb"
outFeatureClass = "{0}".format(row[2])
delimitedField = arcpy.AddFieldDelimiters(env.workspace, "USER_Center")
expression = delimitedField + " = '{0}'".format(row[2])
print(expression)
## Execute FeatureClassToFeatureClass
arcpy.FeatureClassToFeatureClass_conversion(inFeatures, outLocation, outFeatureClass, expression)
The output FCs are supposed to be named after their corresponding locations ('USER_Center"). This field contains no invalid characters, as you can see below (I was testing this code on a table with only 3 rows).
Could someone help me figure out what I'm doing wrong/missing?
Thanks.
Solved! Go to Solution.
Whitespace characters are invalid, and I suspect you have one at the end of your text, i.e., the text is 'NorthEdmond ' instead of 'NorthEdmond' . Try changing:
outFeatureClass = "{0}".format(row[2].strip())
can you print out the expression.
see that capital U suggests it may be making a Unicode character, and I suspect that your path no longer is in raw format and only contains single backslashes.
Whitespace characters are invalid, and I suspect you have one at the end of your text, i.e., the text is 'NorthEdmond ' instead of 'NorthEdmond' . Try changing:
outFeatureClass = "{0}".format(row[2].strip())
That was the answer. Thanks for your help!