<?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: Adding table to Table of Contents in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/adding-table-to-table-of-contents/m-p/463514#M36331</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Arek&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am running the script from a toolbox in ArcMap. I tried your idea anyway but it still doesn't add the table to a data frame in the Table of Contents. I can add it manually through "Add Data". It then creates a new data frame and adds the table. I would like to do the same using a python script if possible.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Arek for your help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Aug 2013 20:13:28 GMT</pubDate>
    <dc:creator>TerrellBeesley</dc:creator>
    <dc:date>2013-08-06T20:13:28Z</dc:date>
    <item>
      <title>Adding table to Table of Contents</title>
      <link>https://community.esri.com/t5/python-questions/adding-table-to-table-of-contents/m-p/463512#M36329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am using Arc 10.1. I am trying to add a table to the Table Of Contents using the following script but it doesn't show up without saving to a new map mxd document. I am using the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument('CURRENT')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd, "layers")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; accidentsTable = arcpy.mapping.TableView("H:/ss/Projects/MaPP/Habitat.gdb/tablename")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddTableView(df, accidentsTable)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This seems to run fine but it's not showing up in the Table of Contents. I've tried using following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshTOC() &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but it still doesn't show up. If I save the mxd file under a different name and reload the file using&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.saveACopy(r"C:\Project\Project2.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the table is in the Table of Contents, but that kind of defeats the purpose.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems like I'm missing something simple. Does anybody have any ideas on how I can add a newly created data table to the active data frame and have it show up in the currently open map document.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Much thanks for any help on this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 23:23:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-table-to-table-of-contents/m-p/463512#M36329</guid>
      <dc:creator>TerrellBeesley</dc:creator>
      <dc:date>2013-08-05T23:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: Adding table to Table of Contents</title>
      <link>https://community.esri.com/t5/python-questions/adding-table-to-table-of-contents/m-p/463513#M36330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you running your script as toolbox, add in or from python window?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In last two cases running:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.MakeTableView_management("H:/ss/Projects/MaPP/Habitat.gdb/tablename", "TMP")&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;will add tabel under name of "TMP" to TOC of mxd in context of which you invoked command (select "List by source" tab in TOC).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Arek&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 12:40:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-table-to-table-of-contents/m-p/463513#M36330</guid>
      <dc:creator>ArkadiuszMatoszka</dc:creator>
      <dc:date>2013-08-06T12:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Adding table to Table of Contents</title>
      <link>https://community.esri.com/t5/python-questions/adding-table-to-table-of-contents/m-p/463514#M36331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Arek&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am running the script from a toolbox in ArcMap. I tried your idea anyway but it still doesn't add the table to a data frame in the Table of Contents. I can add it manually through "Add Data". It then creates a new data frame and adds the table. I would like to do the same using a python script if possible.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Arek for your help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 20:13:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-table-to-table-of-contents/m-p/463514#M36331</guid>
      <dc:creator>TerrellBeesley</dc:creator>
      <dc:date>2013-08-06T20:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Adding table to Table of Contents</title>
      <link>https://community.esri.com/t5/python-questions/adding-table-to-table-of-contents/m-p/463515#M36332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this might be too obvious and apologies if so but did you set an 'table' output parameter when adding your script to toolbox?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 21:02:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-table-to-table-of-contents/m-p/463515#M36332</guid>
      <dc:creator>TimDonoyou</dc:creator>
      <dc:date>2013-08-06T21:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Adding table to Table of Contents</title>
      <link>https://community.esri.com/t5/python-questions/adding-table-to-table-of-contents/m-p/463516#M36333</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Tim, that worked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]26523[/ATTACH]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for the tip. I knew it would be something simple.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 22:18:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-table-to-table-of-contents/m-p/463516#M36333</guid>
      <dc:creator>TerrellBeesley</dc:creator>
      <dc:date>2013-08-06T22:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Adding table to Table of Contents</title>
      <link>https://community.esri.com/t5/python-questions/adding-table-to-table-of-contents/m-p/1193667#M65017</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/117605"&gt;@ArkadiuszMatoszka&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you running your script as toolbox, add in or from python window?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In last two cases running:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE&gt;arcpy.MakeTableView_management("H:/ss/Projects/MaPP/Habitat.gdb/tablename", "TMP")&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;will add tabel under name of "TMP" to TOC of mxd in context of which you invoked command (select "List by source" tab in TOC).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Arek&lt;/SPAN&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This solution is what worked for me. Using arcpy in ArcGIS Pro, I had several times where the output of my process (a table) was not getting added to my TOC. When the table is not added, the next step breaks with the error that the table does not exist or is not supported. It happens, seemingly at random, as I can run it again and it will work. Using this snippet to add the table explicitly adds a small step to the process, but seems to resolve my problem.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 21:00:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-table-to-table-of-contents/m-p/1193667#M65017</guid>
      <dc:creator>SethSobel</dc:creator>
      <dc:date>2022-07-19T21:00:13Z</dc:date>
    </item>
  </channel>
</rss>

