Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Go easy, I'm new to python

I keep getting a kick back that says this: ERROR 000732: Input Features: Dataset 'Database Connections\Wyoming.sde\Supporting_MT_DBO_Geology' does not exist or is not supported Failed to execute (FeatureClassToGeodatabase).

*********UPDATED************* ******HERE'S THE ENTIRE SCRIPT*******

# Import modules
import sys, string, os, datetime, arcpy

# Sets the start time
nowstart = datetime.datetime.now()

# Set location of SDE instance - in this case a special SDE connection just for this script
SDEname = r"C:\Users\jjones\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\Wyoming.sde"
SDEnameShort = r"'Database Connections\Wyoming.sde"


# Set up the log file
LogLoc = r"P:\Database_Backups\SDE\BackupLog_"
LgFile = LogLoc + nowstart.strftime("%Y_%m_%d_%H%M") + ".log"
logfile_out = open(LgFile, 'w')
# Write the start time to the log file
logfile_out.write("Backup process started on " + nowstart.strftime("%Y_%m_%d %H:%M") + "\n")

# Deletes temp timestamp
del nowstart

# Add the Conversion and Data Management Toolboxes to the geoprocessor


#Sets work environment to SDEname
arcpy.env.workspace = SDEname

#Sets environment to overwrite
arcpy.env.overwriteOutput = True

# Resets the start time
nowstart = datetime.datetime.now()

# Creates a variable for naming the backup GDB
YearMonthDayTime = nowstart.strftime("%Y_%m_%d_%H%M")

# Variables and parameters for setting up the backup GDB
outgdb = "PetroPAM_Backup_" + YearMonthDayTime + ".gdb"
outpath = r"P:\Database_Backups"
output = outpath + os.sep + outgdb
print output


#Create the backup GDB
arcpy.CreateFileGDB_management(outpath, outgdb)
print "Created BackupGDB"




# Find and export feature classes in datasets to a backup GDB
logfile_out.write("\nCreating Feature Dataset List...\n")
fc = arcpy.ListFeatureClasses()

dsList = arcpy.ListDatasets("*", "Feature")
print dsList
print "The Datasets"
for dsGEO in dsList:
    outDS = arcpy.ValidateTableName(dsGEO)
    arcpy.CreateFeatureDataset_management(output, outDS)
    fcListGEO = arcpy.ListFeatureClasses("*","",dsGEO)
    print fcListGEO
    print "Feature Classes in Dataset"
    for fcGEO in fcListGEO:
        print fcGEO
        print SDEnameShort + os.sep + outDS + os.sep + fcGEO
        arcpy.FeatureClassToGeodatabase_conversion(SDEnameShort + os.sep + outDS + os.sep + fcGEO, output + outDS)

Any ideas? I'm using ArcMap 10.1

share|improve this question
1  
Your input into the conversion process is your feature dataset (dsGeo), not a single featureclass (fcGeo). Is this what you intended? Since you're choosing to loop through your feature classes I would think the input to this process would be a featureclass. –  Nick Ochoski Jan 13 at 21:50
    
I basically want to copy the data from the sde to a file geodatabase. Will it matter if the dataset is empty and has no feature classes in it? –  joebob Jan 13 at 22:17

1 Answer 1

The errors you are encountering are a direct result of not inputting the correct number of parameters into the tool you are calling. Create Feature Dataset requires both out_dataset_path and out_name.

In addition to this there are some other issues with your code.

The help documentation for the Feature Class to Geodatabase tool states:

The inputs can include shapefiles, coverage feature classes, VPF feature classes, or geodatabase feature classes

You are attempting to input a feature dataset. Since you're choosing to loop through your feature classes I would think the input to this process would be a feature class.

Try this modified version of your code where a feature class in used in place of the feature dataset.

    dsList = arcpy.ListDatasets()
    print dsList
    for dsGEO in dsList:
        arcpy.CreateFeatureDataset_management(dsGEO, **out_name**)
        fcListGEO = arcpy.ListFeatureClasses(dsGEO)
        for fcGEO in fcListGEO:
            arcpy.FeatureClassToGeodatabase_conversion(fcGeo, **output_geodatabase**)

Pending the rest of your code is correct this will loop through each feature class inside of each feature dataset and add it to your geodatabase.

share|improve this answer
    
It says I need to indent the line after the "for dsGEO in dsList". If there is an empty dataset will that matter? –  joebob Jan 13 at 22:15
    
I have updated the code to make the indentation more clear. I would suggest testing with just one dataset that you know to contain featureclasses to ensure that the code runs. After that you can test to see what happens when you input an empty feature class. You can avoid this by ensuring that the dataset contains feature classes (e.g. fc count > 0) –  Nick Ochoski Jan 13 at 22:20
    
I think that's the exact code I pasted in? –  joebob Jan 13 at 22:25
    
I tired it on a database that has feature classes below the dataset and it kicks back the same error message. Do I need to set the environment to the FileGDB? I don't know why it kicks back a message saying a value is required. –  joebob Jan 13 at 22:31
    
Ah - you're missing a required input into the tool. The last line should read: arcpy.FeatureClassToGeodatabase_conversion(fcGeo, output_geodatabase), where 'output_geodatabase' is the path to your geodatabase. This question further explains that specific error: gis.stackexchange.com/questions/50656/… –  Nick Ochoski Jan 13 at 22:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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