<?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 Possible to create tableview in memory and fill in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/possible-to-create-tableview-in-memory-and-fill/m-p/442099#M34617</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Looking to use management AddAttachment tool in ArcPy.&amp;nbsp; Want to add a bunch of attachments without writting a csv file.&amp;nbsp; Basically reading files from disk, creating the row and adding the attachments.&amp;nbsp; Bulk process with 100s thousands of files, don't want to write a csv file on disk with all the entries.&amp;nbsp; Want to create the tableview in memory and populate it with values and use it in the addattachment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any one knows if it can be done&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Mar 2014 20:01:38 GMT</pubDate>
    <dc:creator>AlexanderGray</dc:creator>
    <dc:date>2014-03-18T20:01:38Z</dc:date>
    <item>
      <title>Possible to create tableview in memory and fill</title>
      <link>https://community.esri.com/t5/python-questions/possible-to-create-tableview-in-memory-and-fill/m-p/442099#M34617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Looking to use management AddAttachment tool in ArcPy.&amp;nbsp; Want to add a bunch of attachments without writting a csv file.&amp;nbsp; Basically reading files from disk, creating the row and adding the attachments.&amp;nbsp; Bulk process with 100s thousands of files, don't want to write a csv file on disk with all the entries.&amp;nbsp; Want to create the tableview in memory and populate it with values and use it in the addattachment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any one knows if it can be done&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Mar 2014 20:01:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/possible-to-create-tableview-in-memory-and-fill/m-p/442099#M34617</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2014-03-18T20:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Possible to create tableview in memory and fill</title>
      <link>https://community.esri.com/t5/python-questions/possible-to-create-tableview-in-memory-and-fill/m-p/442100#M34618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've unfortunately never had the chance to fiddle with the AddAttachment tool due to a lack of licensing, but to create in memory tables in arcpy, you would probably do something along these lines:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Made your in memory table and add pertinent data
table = arcpy.CreateTable_management("in_memory", tableName)
arcpy.AddField_management(table, "ID", "LONG", 9)
arcpy.AddField_management(table, "NAME", "TEXT")

# Insert your data
fields = ["ID","NAME"] 
with arcpy.da.InsertCursor(table,fields) as insertcursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in dataToInsert:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insertcursor.insertRow(row)

# Some tools may require a table view ...
arcpy.MakeTableView_management(table, "table_view")

# Make sure to clean up your workspace, especially for larger batch processes
arcpy.Delete_management(table)
arcpy.Delete_management("table_view")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure how this would work with the AddAttachment tool, but this should give a general idea on creating in_memory tables in arcpy.&amp;nbsp; Hope it helps!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:46:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/possible-to-create-tableview-in-memory-and-fill/m-p/442100#M34618</guid>
      <dc:creator>MattEiben</dc:creator>
      <dc:date>2021-12-11T19:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Possible to create tableview in memory and fill</title>
      <link>https://community.esri.com/t5/python-questions/possible-to-create-tableview-in-memory-and-fill/m-p/442101#M34619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This works for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

&amp;nbsp; if arcpy.Exists("in_memory\\matchtable"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management("in_memory\\matchtable")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; ## setup for the attachments
&amp;nbsp; input = r"H:\Documents\ArcGIS\Default.gdb\InstantValues"
&amp;nbsp; inputField = "InstantValues_staname"
&amp;nbsp; matchTable = arcpy.CreateTable_management("in_memory", "matchtable")
&amp;nbsp; matchField = "STATION"
&amp;nbsp; pathField = "Picture"
&amp;nbsp; arcpy.AddField_management(matchTable, matchField, "TEXT")
&amp;nbsp; arcpy.AddField_management(matchTable, pathField, "TEXT")
&amp;nbsp; picFolder = str(outfolder)

&amp;nbsp; ## check to see if matchtable exists and remove attachements if it does
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; fields = ["STATION", "Picture"]
&amp;nbsp; cursor = arcpy.da.InsertCursor(matchTable, fields)
&amp;nbsp; ##go thru the picFolder of .png images to attach 
&amp;nbsp; for file in os.listdir(picFolder):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if str(file).find(".png") &amp;gt; -1:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pos = int(str(file).find("."))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newfile = str(file)[0:pos]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.insertRow((newfile, file))
&amp;nbsp; del cursor

&amp;nbsp; # the input feature class must first be GDB attachments enabled
&amp;nbsp; arcpy.EnableAttachments_management(input)
 
&amp;nbsp; # use the match table with the Add Attachments tool
&amp;nbsp; arcpy.AddAttachments_management(input, inputField, matchTable, matchField, pathField, picFolder)
&amp;nbsp; arcpy.AddMessage("Attachments enabled/created")

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:46:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/possible-to-create-tableview-in-memory-and-fill/m-p/442101#M34619</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T19:46:55Z</dc:date>
    </item>
  </channel>
</rss>

