Python, CopyFeatures

317
6
03-21-2024 07:21 AM
Williams_Gregory
New Contributor II

I'm trying to copy some feature layers from an SQL server to a file geodatabase on my C drive.  The problem I'm running into is when there are some of the feature layers within a dataset on the server and I try to copy the file(s) to a dataset folder on the file geodatabase.  I does working work when there are no dataset folders.

It seems like the "arcpy.management.CopyFeatures()" function doesn't like working with datasets.  I keep getting the following error message:

ERROR 000354: The name contains invalid characters
Failed to execute (CopyFeatures).

Is there a different function for datasets?

Thanks,

0 Kudos
6 Replies
DanPatterson
MVP Esteemed Contributor

can you provide the input and output paths?

000354: The name contains invalid characters.—ArcGIS Pro | Documentation

databases etc may have their own acceptable limits regarding names


... sort of retired...
0 Kudos
Williams_Gregory
New Contributor II

import arcpy, os, sys

arcpy.env.workspace = r"Database Connections\Server - sdeVector.sde\sdeVector.SDEDATAOWNER.Administrative"

arcpy.management.CopyFeatures("sdeVector.SDEDATAOWNER.MunicipalArea", r"C:\Datafiles\GISPro_GeoDatabase\Local_Basemap.gdb\MunicipalArea")

print("Done")

 

"Administrative" is the subfolder or dataset on the server, and I created a dataset on the file geodatabase with the same name.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

There are several tools available for moving data around, maybe give Export Features (Conversion)—ArcGIS Pro | Documentation a try.

0 Kudos
Williams_Gregory
New Contributor II

Tried the export function, but it didn't work.  Keeps giving me an error message about the folder(or file?) already existing.  But it's not there when I click refresh in ArcCatalog.

ERROR 000725: Output Feature Class: Dataset C:\Datafiles\GISPro_GeoDatabase\Local_Basemap.gdb\Administrative already exists.
Failed to execute (ExportFeatures).

 

 

0 Kudos
Williams_Gregory
New Contributor II

Sorry for the delay with an update, I was able to get the datasets updated.  What I did was delete the old dataset folders and their contents, then re-create the empty dataset folders.  And finally use the arcpy.management.CopyFeatures function for each feature layer in each dataset.  It does take a long to run this update, but it does work so i will live with it.

Thanks for all the suggestions!

 

0 Kudos