0

I am trying to create a new script with a hard-coded geodatabase filename, that lists the feature classes it contains to the console. I know there are several ways to do this, but I decided to to use ListFeatureClasses function.

I got the following sample code from ArcGIS website, but I do not know what changes I need to make in order for it to work. I barely started studying Python, so I know very basic stuff, but I would like to get help with this.

import os
import arcpy

# Set the workspace for ListFeatureClasses
arcpy.env.workspace = "c:/base"

# Use the ListFeatureClasses function to return a list of
# shapefiles.
featureclasses = arcpy.ListFeatureClasses()

# Copy shapefiles to a file geodatabase
for fc in featureclasses:
 arcpy.CopyFeatures_management(
  fc, os.path.join("c:/base/output.gdb",
   os.path.splitext(fc)[0]))
3

Change

"c:/base"

to be the path to your file geodatabase. Eg, "C:/path/to/database.gdb"

Change

    arcpy.CopyFeatures_management(
      fc, os.path.join("c:/base/output.gdb",
       os.path.splitext(fc)[0]))

to:

    print fc
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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