I need to write a Python script that is copying. I want to copy a common feature class of these gdb to a single gdb
import os
import arcpy
arcpy.env.workspace = ("D:/Planchas")
workspaces = arcpy.ListWorkspaces("", "Access")
print(workspaces)
for workspace in workspaces:
featureSet = arcpy.ListDatasets("Toponimos")
for fs in featureSet:
featureClasses = arcpy.ListFeatureClasses("Orografia", "Point", fs)
for fc in featureClasses:
arcpy.CopyFeatures_management(
fc,
os.path.join("C:/Users/Prueba",
os.path.splitext(fc)[0]))
When I try to run the code there is no error but the process is not carried out
-
1Please remember to paste a script that doesn't need extensive editing by each person who would want to help you. Clipping out the interpreter noise takes enough time to prevent assistance.Vince– Vince2019年12月30日 02:14:55 +00:00Commented Dec 30, 2019 at 2:14
-
1What happens when you run the code that you have presented? Does it give an error? If so, please include the full error message including line number.PolyGeo– PolyGeo ♦2019年12月30日 04:53:54 +00:00Commented Dec 30, 2019 at 4:53
-
When I try to run the code there is no error but the process is not carried outsergio navarro– sergio navarro2019年12月30日 19:12:39 +00:00Commented Dec 30, 2019 at 19:12
-
What do you mean by a common feature class? A feature class which exists in all geodatabases?Emil Brundage– Emil Brundage2020年01月01日 00:03:18 +00:00Commented Jan 1, 2020 at 0:03
1 Answer 1
There are a few issues in your script.
You should change the workspace for each iteration of the feature datasets within the mdbs. Currently your script is looking for datasets called 'Toponimos" inside your
D:\Planchas
directory.No need to add brackets around the workspace (
arcpy.env.workspace = ("D:/Planchas")
)Also, your output path is not OK if you want to save to a gdb feature class.
import os, arcpy
arcpy.env.workspace = "D:/Planchas"
workspaces = arcpy.ListWorkspaces("", "Access")
print(workspaces)
for workspace in workspaces:
arcpy.env.workspace = workspace
featureSet = arcpy.ListDatasets("Toponimos")
for fs in featureSet:
featureClasses = arcpy.ListFeatureClasses("Orografia", "Point", fs)
for fc in featureClasses:
arcpy.CopyFeatures_management(fc,
os.path.join("C:/Users/Prueba.gdb", fc))
Explore related questions
See similar questions with these tags.