<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Appending Multiple Personal Geodatabase tables in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548847#M42868</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Geoprocessing tools return Result objects, so arcpy.CreateFileGDB_management returns a Result object containing all the various information that Result objects contain.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 25 Aug 2019 03:29:25 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2019-08-25T03:29:25Z</dc:date>
    <item>
      <title>Appending Multiple Personal Geodatabase tables</title>
      <link>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548841#M42862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to append multiple personal geodatabase tables to a 2nd stand-alone personal geodatabase table using a python script.&amp;nbsp; 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".&amp;nbsp; 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".&amp;nbsp; 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.&amp;nbsp; The screenshot below shows the directory structure that I am referring to.&amp;nbsp; Can anyone lead me in the right direction on this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/457520_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;import arcpy.da as da&lt;BR /&gt;import os&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Set Workspace&lt;BR /&gt;workspace = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Create .mdb to Hold Combined Valve &amp;amp; Hydrant Data&lt;BR /&gt;target_geodatabase = arcpy.CreateFileGDB_management(workspace, "CombinedData.gdb")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Load Schema&lt;BR /&gt;arcpy.ImportXMLWorkspaceDocument_management (target_geodatabase, r"W:\Projects\KansasCityMO\Valve And Hydrant\Data\Databases\KCMO_DAILY_FILE.xml", "SCHEMA_ONLY")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Search for Valve &amp;amp; Hydrant Tables and Append to Combined Daily Tables&lt;BR /&gt;for dirpath, dirnames, filenames in da.Walk(workspace, datatype="Table"):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;for filename in filenames:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if filename == "Valve" or "Cannot_Locate_Valve":&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.Append_management(os.path.join(dirpath, filename), target_geodatabase, "TEST", "", "")&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;elif filename == "Hydrant":&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.Append_management(os.path.join(dirpath, filename), target_geodatabase, "TEST", "", "")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2019 20:37:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548841#M42862</guid>
      <dc:creator>shildebrand</dc:creator>
      <dc:date>2019-08-20T20:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Appending Multiple Personal Geodatabase tables</title>
      <link>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548842#M42863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Samuel,&lt;/P&gt;&lt;P&gt;after a quick look without trying it out:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The second parameter of Append_management must be a dataset (one of your target tables and not a geodatabase workspace)&lt;/LI&gt;&lt;LI&gt;Instead of using the xml&amp;nbsp; you may create a table inside your geodatabase with&amp;nbsp;&lt;SPAN style="color: #595959; background-color: #f8f8f8;"&gt;CreateTable_management. You have the option to pass a table template to match the desired schema or you can create it empty and then you start adding&amp;nbsp;fields with&amp;nbsp;&lt;SPAN&gt;AddField_management&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8;"&gt;Alberto&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2019 13:17:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548842#M42863</guid>
      <dc:creator>AlbertoAloe</dc:creator>
      <dc:date>2019-08-21T13:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Appending Multiple Personal Geodatabase tables</title>
      <link>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548843#M42864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Alberto,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know how to reference the target table that was created earlier in the script when the xml document was imported?&amp;nbsp; Without referencing the direct path (since a new empty table with a different path will be created every time the script is run).&amp;nbsp; I'm thinking something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;target_geodatabase + "Daily_Valve"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;os.path.join(target_geodatabase, "Daily_Valve")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2019 20:44:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548843#M42864</guid>
      <dc:creator>shildebrand</dc:creator>
      <dc:date>2019-08-21T20:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: Appending Multiple Personal Geodatabase tables</title>
      <link>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548844#M42865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;target_geodatabase + "\\&lt;SPAN style="background-color: #ffffff;"&gt;Daily_Valve&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;target_geodatabase + r"\&lt;/SPAN&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Daily_Valve&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; "&gt;os.path.join(target_geodatabase, "Daily_Valve")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; "&gt;Alberto&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2019 10:20:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548844#M42865</guid>
      <dc:creator>AlbertoAloe</dc:creator>
      <dc:date>2019-08-22T10:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Appending Multiple Personal Geodatabase tables</title>
      <link>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548845#M42866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Alberto,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts as to why I get this error when using any of those?:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TypeError: unsupported operand type(s) for +: 'Result' and 'str'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;import arcpy.da as da&lt;BR /&gt;import os&lt;/P&gt;&lt;P&gt;# Set Workspace&lt;BR /&gt;workspace = r"W:\Projects\KansasCityMO\Valve And Hydrant\Data\PFdata\Export\2019\0819\0813"&lt;/P&gt;&lt;P&gt;# Create .mdb to Hold Combined Valve &amp;amp; Hydrant Data&lt;BR /&gt;target_geodatabase = arcpy.CreateFileGDB_management(workspace, "CombinedData.gdb")&lt;/P&gt;&lt;P&gt;# Load Schema&lt;BR /&gt;arcpy.ImportXMLWorkspaceDocument_management (target_geodatabase, r"W:\Projects\KansasCityMO\Valve And Hydrant\Data\Databases\KCMO_DAILY_FILE.xml", "SCHEMA_ONLY")&lt;/P&gt;&lt;P&gt;# Set the current workspace&lt;BR /&gt;arcpy.env.workspace = workspace&lt;/P&gt;&lt;P&gt;# List all&amp;nbsp;personal geodatabase tables in the current workspace and&amp;nbsp;append to Daily_Valve table&lt;BR /&gt;workspaces = arcpy.ListWorkspaces("*", "ACCESS")&lt;BR /&gt;for workspace in workspaces:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;arcpy.env.workspace = workspace&lt;BR /&gt;&amp;nbsp; &amp;nbsp;tables = set(arcpy.ListTables("Valve") + arcpy.ListTables("Cannot_Locate_Valve"))&lt;BR /&gt;&amp;nbsp; &amp;nbsp;for table in tables:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;arcpy.Append_management(table, target_geodatabase + "\\Daily_Valve", "NO_TEST")&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2019 15:51:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548845#M42866</guid>
      <dc:creator>shildebrand</dc:creator>
      <dc:date>2019-08-22T15:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Appending Multiple Personal Geodatabase tables</title>
      <link>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548846#M42867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Because if you write...&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; "&gt;target_geodatabase = arcpy.CreateFileGDB_management(workspace, "CombinedData.gdb")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;you are assigning to the variable target_geodatabase what &lt;SPAN&gt;arcpy.CreateFileGDB_management is returning: an object of type workspace that cannot be concatenated with a string.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;You have to concatenate&amp;nbsp;the full path to your geodb with the table name&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;Alberto&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Aug 2019 15:28:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548846#M42867</guid>
      <dc:creator>AlbertoAloe</dc:creator>
      <dc:date>2019-08-24T15:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: Appending Multiple Personal Geodatabase tables</title>
      <link>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548847#M42868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Geoprocessing tools return Result objects, so arcpy.CreateFileGDB_management returns a Result object containing all the various information that Result objects contain.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Aug 2019 03:29:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548847#M42868</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-08-25T03:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: Appending Multiple Personal Geodatabase tables</title>
      <link>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548848#M42869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/result.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/result.htm"&gt;Result—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2019 15:16:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548848#M42869</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2019-08-27T15:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: Appending Multiple Personal Geodatabase tables</title>
      <link>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548849#M42870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Alberto for your help.&amp;nbsp; I was able to create a variable that concatenates the full path to the newly created geodatabase name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;import arcpy.da as da&lt;BR /&gt;import os&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Process: Delete Features From Daily File&lt;BR /&gt;arcpy.TruncateTable_management(r"W:\Projects\KansasCityMO\Valve And Hydrant\Data\Databases\KCMO_Daily_File.gdb\Valve")&lt;BR /&gt;arcpy.TruncateTable_management(r"W:\Projects\KansasCityMO\Valve And Hydrant\Data\Databases\KCMO_Daily_File.gdb\Hydrant")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Script arguments&lt;BR /&gt;workspace = arcpy.GetParameterAsText(0) # workspace folder containing exported .mdb's&lt;BR /&gt;outValveFC = arcpy.GetParameterAsText(1) # output valve feature class&lt;BR /&gt;outHydrantFC = arcpy.GetParameterAsText(2) # output hydrant feature class&lt;BR /&gt;spRef = arcpy.GetParameterAsText(3) # output coordinate system&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Set the current workspace&lt;BR /&gt;arcpy.env.workspace = workspace&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Create .gdb to Hold Combined Valve &amp;amp; Hydrant Data&lt;BR /&gt;arcpy.CreateFileGDB_management(workspace, "KCMO_Workspace_2019.gdb")&lt;BR /&gt;fileGDB = os.path.join(workspace, "KCMO_Workspace_2019.gdb")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# List all personal geodatabase tables in the current workspace and export to filegdb&lt;BR /&gt;workspaces = arcpy.ListWorkspaces("*", "ACCESS")&lt;BR /&gt;for dailyFolder in workspaces:&lt;BR /&gt; arcpy.env.workspace = dailyFolder&lt;BR /&gt; tables = set(arcpy.ListTables("Valve") + arcpy.ListTables("Cannot_Locate_Valve") + arcpy.ListTables("Shutdown_Valve") + arcpy.ListTables("Hydrant") + arcpy.ListTables("CNL_Hydrant"))&lt;BR /&gt; for table in tables:&lt;BR /&gt; arcpy.TableToGeodatabase_conversion(table, fileGDB)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Aug 2019 19:27:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548849#M42870</guid>
      <dc:creator>shildebrand</dc:creator>
      <dc:date>2019-08-30T19:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Appending Multiple Personal Geodatabase tables</title>
      <link>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548850#M42871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just an observation of your script. You are importing all of arcpy, which includes arcpy.env and arcpy.da so you don't need to import those explicitly. Especially since you are still calling it as arcpy.env&amp;nbsp;and don't appear to be using arcpy.da. This will do:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:44:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548850#M42871</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-11T23:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Appending Multiple Personal Geodatabase tables</title>
      <link>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548851#M42872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Blake, I appreciate the feedback!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Sep 2019 15:49:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/appending-multiple-personal-geodatabase-tables/m-p/548851#M42872</guid>
      <dc:creator>shildebrand</dc:creator>
      <dc:date>2019-09-03T15:49:39Z</dc:date>
    </item>
  </channel>
</rss>

