<?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 Save memory while Concatenating vertically in loop in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Save-memory-while-Concatenating-vertically-in-loop/m-p/718508#M90140</link>
    <description>&lt;P&gt;Greetings!&lt;/P&gt;&lt;P&gt;I am trying to Concatenate query results, from several tables in a directory, into one single table. I am using loop to read/query the tables and concatenate the results. The result table is fine but each intermediate concatenated tables keeps opening consuming the memory.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for any suggestions to to avoid opening each intermediate result tables but just updating the data frame which can be displayed as the result table only after the loop is completed.&lt;BR /&gt;&lt;BR /&gt;I am using JMP 17 Pro.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);&lt;BR /&gt;dirLoc=Pick Directory("Select a directory", "myDirectory\");
fileList = Files In Directory(dirLoc);
dt1 = open(dirLoc || fileList[1]);
dt1 &amp;lt;&amp;lt; Select Where( :Amount &amp;gt;= 500 );
x=dt1 &amp;lt;&amp;lt; Subset ( Output Table Name("T1") );
Close(dt1, NoSave);
For(i = 2, i &amp;lt;= N Items( fileList ), i++,
	dt = open(dirLoc || fileList[i] );
	dt &amp;lt;&amp;lt; Select Where( :Amount &amp;gt;= 500 );
	y = dt &amp;lt;&amp;lt; Subset ( Output Table Name("Temp"));
	x = x &amp;lt;&amp;lt; Concatenate( y);
	Close(dt, NoSave);
	Close(y, NoSave);
);
result = x&amp;lt;&amp;lt;Subset ( Output Table Name("Result"));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jan 2024 17:31:53 GMT</pubDate>
    <dc:creator>monir</dc:creator>
    <dc:date>2024-01-26T17:31:53Z</dc:date>
    <item>
      <title>Save memory while Concatenating vertically in loop</title>
      <link>https://community.jmp.com/t5/Discussions/Save-memory-while-Concatenating-vertically-in-loop/m-p/718508#M90140</link>
      <description>&lt;P&gt;Greetings!&lt;/P&gt;&lt;P&gt;I am trying to Concatenate query results, from several tables in a directory, into one single table. I am using loop to read/query the tables and concatenate the results. The result table is fine but each intermediate concatenated tables keeps opening consuming the memory.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for any suggestions to to avoid opening each intermediate result tables but just updating the data frame which can be displayed as the result table only after the loop is completed.&lt;BR /&gt;&lt;BR /&gt;I am using JMP 17 Pro.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);&lt;BR /&gt;dirLoc=Pick Directory("Select a directory", "myDirectory\");
fileList = Files In Directory(dirLoc);
dt1 = open(dirLoc || fileList[1]);
dt1 &amp;lt;&amp;lt; Select Where( :Amount &amp;gt;= 500 );
x=dt1 &amp;lt;&amp;lt; Subset ( Output Table Name("T1") );
Close(dt1, NoSave);
For(i = 2, i &amp;lt;= N Items( fileList ), i++,
	dt = open(dirLoc || fileList[i] );
	dt &amp;lt;&amp;lt; Select Where( :Amount &amp;gt;= 500 );
	y = dt &amp;lt;&amp;lt; Subset ( Output Table Name("Temp"));
	x = x &amp;lt;&amp;lt; Concatenate( y);
	Close(dt, NoSave);
	Close(y, NoSave);
);
result = x&amp;lt;&amp;lt;Subset ( Output Table Name("Result"));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 17:31:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Save-memory-while-Concatenating-vertically-in-loop/m-p/718508#M90140</guid>
      <dc:creator>monir</dc:creator>
      <dc:date>2024-01-26T17:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Save memory while Concatenating vertically in loop</title>
      <link>https://community.jmp.com/t5/Discussions/Save-memory-while-Concatenating-vertically-in-loop/m-p/718525#M90143</link>
      <description>&lt;P&gt;You need to append the concatenated tables.&amp;nbsp; By default JMP concatenates tables into a new table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);dirLoc=Pick Directory("Select a directory", "myDirectory\");
fileList = Files In Directory(dirLoc);
dt1 = open(dirLoc || fileList[1]);
dt1 &amp;lt;&amp;lt; Select Where( :Amount &amp;gt;= 500 );
x=dt1 &amp;lt;&amp;lt; Subset ( Output Table Name("T1") );
Close(dt1, NoSave);
For(i = 2, i &amp;lt;= N Items( fileList ), i++,
	dt = open(dirLoc || fileList[i] );
	dt &amp;lt;&amp;lt; Select Where( :Amount &amp;gt;= 500 );
	y = dt &amp;lt;&amp;lt; Subset ( Output Table Name("Temp"));
	x &amp;lt;&amp;lt; Concatenate( y, "Append to First Table" );
	Close(dt, NoSave);
	Close(y, NoSave);
);
result = x&amp;lt;&amp;lt;Subset ( Output Table Name("Result"));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 20:02:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Save-memory-while-Concatenating-vertically-in-loop/m-p/718525#M90143</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2024-01-26T20:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Save memory while Concatenating vertically in loop</title>
      <link>https://community.jmp.com/t5/Discussions/Save-memory-while-Concatenating-vertically-in-loop/m-p/718526#M90144</link>
      <description>&lt;P&gt;Thanks for your suggestion to append instead of concatenation. Actually I tried appending as well as shown below. The problem is, it pops up all the intermediate table every time it is appended in the loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;x &amp;lt;&amp;lt; Concatenate(x,y);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Any thought?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 20:20:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Save-memory-while-Concatenating-vertically-in-loop/m-p/718526#M90144</guid>
      <dc:creator>monir</dc:creator>
      <dc:date>2024-01-26T20:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: Save memory while Concatenating vertically in loop</title>
      <link>https://community.jmp.com/t5/Discussions/Save-memory-while-Concatenating-vertically-in-loop/m-p/718539#M90145</link>
      <description>&lt;P&gt;There might be some misunderstanding here.&amp;nbsp; Doing &lt;CODE class=" language-jsl"&gt;x &amp;lt;&amp;lt; Concatenate( x, y )&lt;/CODE&gt; will not update &lt;CODE class=" language-jsl"&gt;x&lt;/CODE&gt;, it will create a new table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To update &lt;CODE class=" language-jsl"&gt;x&lt;/CODE&gt; with the values of &lt;CODE class=" language-jsl"&gt;y&lt;/CODE&gt;, use the literal expression &lt;CODE class=" language-jsl"&gt;x &amp;lt;&amp;lt; Concatenate( y, "Append to First Table" )&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, think about doing all this as private tables to conserve resources, then at the end show the table, like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dirLoc = Pick Directory( "Select a directory", "myDirectory\" );
fileList = Files In Directory( dirLoc );
dt1 = Open( dirLoc || fileList[1], Private );
dt1 &amp;lt;&amp;lt; Select Where( :Amount &amp;gt;= 500 );
x = dt1 &amp;lt;&amp;lt; Subset( Output Table Name( "T1" ), Private );
Close( dt1, NoSave );

For( i = 2, i &amp;lt;= N Items( fileList ), i++,
	dt = Open( dirLoc || fileList[i], Private );
	dt &amp;lt;&amp;lt; Select Where( :Amount &amp;gt;= 500 );
	y = dt &amp;lt;&amp;lt; Subset( Output Table Name( "Temp" ), Private );
	x &amp;lt;&amp;lt; Concatenate( y, "Append to First Table" );
	Close( dt, NoSave );
	Close( y, NoSave );
);

x &amp;lt;&amp;lt; Set Name( "Result" );
x &amp;lt;&amp;lt; New Data View;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 22:24:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Save-memory-while-Concatenating-vertically-in-loop/m-p/718539#M90145</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2024-01-26T22:24:43Z</dc:date>
    </item>
  </channel>
</rss>

