jdifilippo

ERROR 000732: Trying to copy shapefile into geodatabase

Discussion created by jdifilippo on Jan 4, 2011
Latest reply on Jan 5, 2011 by jdifilippo
I am very new to writing scripts in Python.  I am trying to follow an example in a tutorial that I'm reading that copies shapefiles from a folder into a geodatabase.  Here is what I have at the moment:

#Import COM dispatch and sys
from win32com.client import Dispatch
import sys

#Create Geoprocessor object
GP = Dispatch("esriGeoprocessing.GpDispatch.1")

#Set the input workspace
GP.Workspace = "E:/gis_py_ex/shapefiles"
try:
   
    #Get a list of the featureclasses
    fcs = GP.ListFeatureClasses("*")

    #Reset the enumeration to make sure the first object is returned
    fcs.reset()

    #Get the first feature class name
    fc = fcs.next()
 
    while fc:
        #Copy the features from the workspace to a geodatabase
        GP.Workspace = "E:/gis_py_ex/results/Testing.gdb"
        outfc = GP.ValidateTableName(fc)
        GP.CopyFeatures_management(fc, outfc)
        #Get the next feature class name
        fc = fcs.next()

except:
    GP.AddMessage(GP.GetMessages(2))
    print GP.GetMessages(2)

Every time I run it I get "Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset Buffer_of_Parcels.shp does not exist or is not supported
Failed to execute (CopyFeatures)."

The shapefile does exist and I checked the path names a hundred times already and everything seems to be correct and in the correct format.  I've been trying to debug this script for about 3 hours now and am making no progress.  Also, does anyone know of a good book that takes you through step-by-step and actually teaches you how to write geoprocessing scripts.  The one I'm using right now is very inconsistent and so far every example I've tried does not seem to work the way it's written in the tutorial.

Any help will be greatly appreciated.  Thank you in advance.

Outcomes