Hi everyone,
I am trying to append multiple personal geodatabase tables to a 2nd stand-alone personal geodatabase table using a python script. The idea here is that the user would select a workspace folder that has multiple personal geodatabases (.mdb's) that each have tables named "Valve", "Hydrant", and "Cannot_Locate_Valve". The script would then create a new file geodatabase ("CombinedData.gdb") and import an .xml file that has the following two tables: "Daily_Valve" and "Daily_Hydrant". The script will then append all tables named "Valve" or "Cannot_Locate_Valve" into the just created "Daily_Valve" and append all tables named "Hydrant" into the "Daily_Hydrant" table. The screenshot below shows the directory structure that I am referring to. Can anyone lead me in the right direction on this?
import arcpy
from arcpy import env
import arcpy.da as da
import os
#Set Workspace
workspace = arcpy.GetParameterAsText(0)
#Create .mdb to Hold Combined Valve & Hydrant Data
target_geodatabase = arcpy.CreateFileGDB_management(workspace, "CombinedData.gdb")
#Load Schema
arcpy.ImportXMLWorkspaceDocument_management (target_geodatabase, r"W:\Projects\KansasCityMO\Valve And Hydrant\Data\Databases\KCMO_DAILY_FILE.xml", "SCHEMA_ONLY")
#Search for Valve & Hydrant Tables and Append to Combined Daily Tables
for dirpath, dirnames, filenames in da.Walk(workspace, datatype="Table"):
for filename in filenames:
if filename == "Valve" or "Cannot_Locate_Valve":
arcpy.Append_management(os.path.join(dirpath, filename), target_geodatabase, "TEST", "", "")
elif filename == "Hydrant":
arcpy.Append_management(os.path.join(dirpath, filename), target_geodatabase, "TEST", "", "")
Thanks Blake, I appreciate the feedback!