Converting folder of shape files to geodatabase

3604
3
08-31-2011 04:07 PM
RickWarner
New Contributor III
I have a folder of 20 shape files and would like to covert folder to geodatabase, the code below will work and list the feature classes, but won't convert to geodatabase.  What am I doing wrong?

import arcpy
>>> from arcpy import env
>>> env.workspace = "D:/GIS/Data/Aug_Files"
>>> fcs = arcpy.ListFeatureClasses("*")
>>> arcpy.FeatureClassToGeodatabase_conversion("D:/GIS/Data/Aug_Files", "D:/GIS/PBCO2011/Planning.gdb")

The error message I get is "Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 000732: Input Features: Dataset D:/GIS/Data/Aug_Files does not exist or is not supported .

Any ideas??
Tags (2)
0 Kudos
3 Replies
ModyBuchbinder
Esri Regular Contributor
Hi Rick

The FeatureClassToGeodatabase_conversion get a comma delimited list of feature classes.
You should build this list from the ListFeatureClasses
Try something like this:

   s = "[ "
    for fc in fcList:
        print fc
        s = s + '"' + fc + '"' + " ,"

    # delete last comma and close brackets   
    s = s[0:len(s) - 1] + " ]"

have fun
Mody
0 Kudos
StephanieWendel
Esri Contributor
I think it's the "D:/GIS/Data/Aug_Files" in this line of code that is causing the problem.
arcpy.FeatureClassToGeodatabase_conversion("D:/GIS/Data/Aug_Files", "D:/GIS/PBCO2011/Planning.gdb")


Mody is right that you need to put your list of elements in this spot. Another way you can do it is like this:

import arcpy
from arcpy import env
env.workspace = "D:/GIS/Data/Aug_Files"
fcs = arcpy.ListFeatureClasses("*")
for fc in fcs:
    arcpy.FeatureClassToGeodatabase_conversion(fc, "D:/GIS/PBCO2011/Planning.gdb")


The listFeatureClasses method link in the Help also has a sample of moving shapefiles into a geodatabase using the copyFeatures_management tool. See this link for more information on it: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/ListFeatureClasses/000v0000001n000000/
0 Kudos
RickWarner
New Contributor III
Thanks Stephanie and Mody, I got Stephanies to work right of way, still trying yours Mody. Again thanks so much.
0 Kudos