Individually I will Export the gdb to XML Workspace then import that into the personnel geodatabase and all Domains go over fine. But...
Let's Say I have several file geodatabase in a folder and Each of the file geodatabase has 1 feature dataset name "URS" and rest are feature classes. "URS" Feature dataset has several feature class as well.
The task for me is to convert Multiple file geodatabase into multiple Personnel geodatabase without including "URS" Feature datasets. If the Geodatabase don't have "URS" Feature dataset or any other feature classes then the python program will create an empty personnel geodatabase.
I am using pyscripter and below mentioned concept is not workin for a single geodatabase. How can I convert multiple File geodatabase (.gdb) into multiple Personal geodatabase (.mdb)?
# Import system modules
import arcpy
# Set environment settings
arcpy.env.workspace = "I:\python\Multiplegdb"
print arcpy.env.workspace
# Set local variables
inFeatures = r'I:\python\Multiplegdb\ABC.gdb'
print inFeatures
outLocation = r'I:\python\Multiplegdb\ABC_Output.mdb'
print outLocation
# Execute TableToGeodatabase
arcpy.FeatureClassToGeodatabase_conversion(inFeatures, outLocation)
enter image description here
enter image description here
-
1Welcome to GIS SE! As a new user be sure to take our Tour. As it stands I think your question is too broad for our focussed Q&A format because it seems to be simply stating your problem and then asking for "input or code in python". I recommend that you edit your question to say precisely what you have tried and where you are stuck because we are not a code writing service.PolyGeo– PolyGeo ♦2015年04月17日 22:21:16 +00:00Commented Apr 17, 2015 at 22:21
-
When you say "personnel geodatabases", do you mean personal (*.mdb) geodatabases?PolyGeo– PolyGeo ♦2015年04月17日 23:22:24 +00:00Commented Apr 17, 2015 at 23:22
-
Yes.....Can you please remove a hold on my questionaccedesoft– accedesoft2015年04月19日 13:23:11 +00:00Commented Apr 19, 2015 at 13:23
-
Do you need the feature classes contained within the "URS" feature dataset to transfer to the output personal geodatabase?Aaron– Aaron ♦2015年04月19日 13:35:47 +00:00Commented Apr 19, 2015 at 13:35
-
hello Aaron,No I don't need URS feature dataset in the .mdb. I wanted to export all individual .gdb's to individual .mdb's and the .mdb name will be same as .gdb.accedesoft– accedesoft2015年04月19日 20:54:40 +00:00Commented Apr 19, 2015 at 20:54
1 Answer 1
Here is one approach that performs the following actions:
- Create a new .mdb with old FGDB name, but in new workspace
- Find all FC's in FGDB--take into account empty FDS's
- Copy all FC's to .mdb
import arcpy, os
arcpy.env.workspace = r'C:\temp\inws'
inws = arcpy.env.workspace
outws = r'C:\temp\outws'
fgdb = arcpy.ListWorkspaces(workspace_type = "fileGDB")
counter = 1
for f in fgdb:
# Define the output .mdb name
name = os.path.basename(f).split(".")[0]
# Create a new personal gdb (.mdb)
arcpy.CreatePersonalGDB_management(outws, name)
outgdb = os.path.join(outws, name + ".mdb")
# Get the FC's in FDS and copy to .mdb
arcpy.env.workspace = os.path.join(inws, f, "")
fcs1 = arcpy.ListFeatureClasses()
for fc in fcs1:
arcpy.CopyFeatures_management(fc, os.path.join(outgdb, fc))
# Get stand-alone FC's and copy to .mdb
arcpy.env.workspace = os.path.join(inws, f, "URS")
fcs2 = arcpy.ListFeatureClasses()
# Make sure there are FC's in the FDS
if fcs2 != None:
for fc in fcs2:
arcpy.CopyFeatures_management(fc, os.path.join(outgdb, fc))
print "%s of %s workspaces converted" % (counter, len(fgdb))
counter = counter + 1
print "Processing complete."