1

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

asked Dec 29, 2019 at 19:00
4
  • 1
    Please 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. Commented Dec 30, 2019 at 2:14
  • 1
    What 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. Commented Dec 30, 2019 at 4:53
  • When I try to run the code there is no error but the process is not carried out Commented Dec 30, 2019 at 19:12
  • What do you mean by a common feature class? A feature class which exists in all geodatabases? Commented Jan 1, 2020 at 0:03

1 Answer 1

1

There are a few issues in your script.

  1. 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.

  2. No need to add brackets around the workspace (arcpy.env.workspace = ("D:/Planchas"))

  3. 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))
answered Jan 7, 2020 at 8:52

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.