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.

This seems like a simple problem, but I have not found a way to accomplish it. I am writing a script that needs to record the paths of everything inside of a geodatabase to a text file, and later copy those files to a new location and zip them up.

I have been able to use arcpy.ListFeatureClasses to grab feature classes, and arcpy.ListRasters, and arcpy.ListDatasets, but how do I obtain a list of, say, Address Locators in my gdb? I haven't found a way to do it with arcpy. There should be a simple function that lists all of the contents of a geodatabase. Is there one I'm missing? Or is there any other way to accomplish this in python?

share|improve this question
1  
So is the mission here to copy the entire geodatabase (is it a file geodatabase) to another location and zip it up, or is there more (like the writing of the paths out to a text file)? –  Chad Cooper Feb 15 '12 at 2:57
1  
I addressed this in my question. I said "I am writing a script that needs to record the paths of everything inside of a geodatabase to a text file". Basically, I'm copying certain contents of a gdb (sometimes the entire thing) to an identically-named gdb which is then zipped up and given to one of our customers as a data update. –  Tanner Feb 15 '12 at 20:18
    
The text file keeps track of which items were put into the zip file. –  Tanner Feb 15 '12 at 21:40
add comment

1 Answer 1

If your goal is simply copying a geodatabase with (most?) everything intact, you could use Copy_management to copy it to a file geodatabase, which you could then zip up using the Python zipfile module. There are also geoprocessing tools for geodatabase replication but I am not sure if address locators are included.

I am not aware of a way to list address locators with arcpy. You could suggest it on ArcGIS Ideas.

The last possibility I would suggest -- and this is definitely in the "any other way" category due to its complexity -- is to export the geodatabase to an ESRI XML Workspace document and parse it with Python's ElementTree XML API or lxml.

Currently there is no built-in way in arcpy to export an XML workspace document -- that's supposedly coming in 10.1 according to this ArcGIS Ideas post. However, you could write an ArcObjects command line application (like this one) and call it from Python using the subprocess module. Again I am not sure if things like address locators are included in the XML output though.

share|improve this answer
add comment

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.