<?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: How to loop through rows from groups created by 2 columns in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/597334#M80090</link>
    <description>&lt;P&gt;Yes, that was actually very useful. The file_list variable was confusing, since it is not strictly needed to open to the files (but; I take it; that it is useful later on when closing all files again (?), for example, or some other manipulation). I have to admit that it also took me some time to wrap my head around the "file_path" variable, which is assigned to a different file path at every iteration, and that it doesn't matter what it is called. (In my head, I just interpret it now as a vehicle that picks one file path after the other from the filepaths_to_open list and lets the user do "something" with it.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you! Every week a tiny growth of knowledge is better that none at all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.s.: The below I was only able to write based on my understanding of your explanations. Again, very useful.&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 );

filepaths_to_open = {"$SAMPLE_DATA/Big Class.jmp", "$SAMPLE_DATA/Probe.jmp", "$SAMPLE_DATA/Iris.jmp"};

For Each( {file_path}, filepaths_to_open, Open( file_path ) );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 05 Feb 2023 19:26:49 GMT</pubDate>
    <dc:creator>Ressel</dc:creator>
    <dc:date>2023-02-05T19:26:49Z</dc:date>
    <item>
      <title>How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/594751#M79864</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a pretty simple question but unable to find the exact answer from the forum. Here's my sample data table:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nthai_1-1675063870291.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49599iA26991EA5273D002/image-size/medium?v=v2&amp;amp;px=400" role="button" title="nthai_1-1675063870291.png" alt="nthai_1-1675063870291.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically it has 4 columns, and i need to loop through each of combination items generating from "group 1" and "group 2", but if and only when "item" # is different then open the all&amp;nbsp; file path in "path" column. For example on first 2 rows, we have the combination is "aA", and because items also different so the script need to open both file path 1 and 2.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:39:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/594751#M79864</guid>
      <dc:creator>nthai</dc:creator>
      <dc:date>2023-06-08T16:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595173#M79888</link>
      <description>&lt;P&gt;Hi, the below at least starts what you want to do. You will only have to change the "&lt;CODE class=" language-jsl"&gt;Print( dtTemp:path[j], dtTemp:path[j + 1] )"&lt;/CODE&gt; part with the function to open a file.&lt;/P&gt;&lt;P&gt;Unfortunately, however, the way I wrote it, this script prints "file path 6" twice to the log, so it will also open "file path6" twice if modified accordingly. I am sure there is a way around it (like checking whether a file path has already been opened maybe), but it is getting late here. Anyway, if I figure out how to do the rest as well, I'll let you know. Feedback is appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = New Table( "today's challenge",
	Add Rows( 7 ),
	New Column( "group1",
		Character,
		"Nominal",
		Set Values( {"a", "a", "a", "a", "c", "c", "c"} )
	),
	New Column( "group2",
		Character,
		"Nominal",
		Set Values( {"A", "A", "B", "B", "A", "A", "A"} ),
		Set Display Width( 70 )
	),
	New Column( "item",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 3, 2, 4, 5, 7, 9] )
	),
	New Column( "path",
		Character,
		"Nominal",
		Set Selected,
		Set Values(
			{"file path 1", "file path 2", "file path 3", "file path 4",
			"file path 5", "file path 6", "file path 7"}
		)
	)
);

dt &amp;lt;&amp;lt; New Column( "PairedGroup", formula( :group1 || :group2 ) );

PairedGroupList = Associative Array( dt:PairedGroup ) &amp;lt;&amp;lt; Get Keys;

dt &amp;lt;&amp;lt; Clear Column Selection;

For( i = 1, i &amp;lt;= N Items( PairedGroupList ), i++,
	dt &amp;lt;&amp;lt; Select Where( :PairedGroup == PairedGroupList[i] );
	dtTemp = dt &amp;lt;&amp;lt; Subset( Invisible, Selected Rows );
	For( j = 1, j &amp;lt;= N Rows( dtTemp ), j++,
		If( dtTemp:item[j] != dtTemp:item[j + 1],
			Print( dtTemp:path[j], dtTemp:path[j + 1] )
		)
	);
	Close( dtTemp, no save );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 20:41:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595173#M79888</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2023-01-30T20:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595201#M79890</link>
      <description>&lt;P&gt;Please investigate&amp;nbsp;NChooseK Matrix() and see if it's right for you.&amp;nbsp; In the scripting index it's described as: Creates a matrix of nChooseK(n,k) rows and K columns forming all the combinations of k integers from 1 to n.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wonder if it can be changed to work with character data types?&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 );
Print( NChooseK Matrix( 5, 3 ) );

__________________________
Prints:
[	1 2 3, 
	1 2 4, 
	1 2 5, 
	1 3 4, 
	1 3 5, 
	1 4 5, 
	2 3 4, 
	2 3 5, 
	2 4 5, 
	3 4 5]&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Jan 2023 21:52:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595201#M79890</guid>
      <dc:creator>StarfruitBob</dc:creator>
      <dc:date>2023-01-30T21:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595223#M79892</link>
      <description>&lt;P&gt;I'm not exactly sure I understand the problem correctly but below are three different options using, Col Sum/Col Cumulative Sum and Col Max(ColSum())&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(8),
	Compress File When Saved(1),
	New Column("g1", Character, "Nominal", Set Values({"a", "a", "a", "a", "a", "c", "c", "c"})),
	New Column("g2", Character, "Nominal", Set Values({"A", "A", "B", "B", "B", "A", "A", "A"})),
	New Column("i", Numeric, "Continuous", Format("Best", 12), Set Values([1, 3, 2, 4, 4, 5, 7, 9])),
	New Column("p",
		Character,
		"Nominal",
		Set Values({"filepath1", "filepath2", "filepath3", "filepath4", "filepath4.1", "filepath5", "filepath6", "filepath7"})
	)
);

// depending how we handle duplicated g1+g2+i we would use different formulas
// if we won't open any
new_col = dt &amp;lt;&amp;lt; New Column("ValidFile", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(
	Col Sum(1, :g1, :g2, :i); 
));

/*
// if we open the first one
new_col = dt &amp;lt;&amp;lt; New Column("ValidFile", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(
	Col Cumulative Sum(1, :g1, :g2, :i); 
));
*/

/*
// if we don't open g1+g2 at all
new_col = dt &amp;lt;&amp;lt; New Column("ValidFile", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(
	Col Max(Col Sum(1, :g1, :g2, :i), :g1, :g2)
));
*/

rows_to_open = dt &amp;lt;&amp;lt; Get Rows Where(:ValidFile == 1);
filepaths_to_open = dt[rows_to_open, "p"];
show(filepaths_to_open);
// dt &amp;lt;&amp;lt; Delete Column(new_col);

// To open files loop over filepaths_to_open
stop();
file_list = {};
For Each({file_path}, filepaths_to_open,
	Insert Into(file_list, Open(file_path));
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1675116098849.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49654i75C45A1ADA0F346D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1675116098849.png" alt="jthi_0-1675116098849.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Idea is that we pick the rows where ValidFile is 1 and then open those files. This image demonstrates the calculations for the three different formulas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&lt;/P&gt;
&lt;P&gt;Fixed old reference&amp;nbsp;&lt;CODE class=" language-jsl"&gt;rows_to_open1&lt;/CODE&gt;&amp;nbsp;to&amp;nbsp;&lt;CODE class=" language-jsl"&gt;rows_to_open&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 06:12:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595223#M79892</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-01-31T06:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595235#M79893</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/15435"&gt;@Ressel&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think it would be easiest to re-think the looping structure, but you could make the current one also work they way you want without double printing: keep a list of what has been printed or figure out some sort of additional logic to prevent that from happening . I think the idea below should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
For( i = 1, i &amp;lt;= N Items( PairedGroupList ), i++,
	dt &amp;lt;&amp;lt; Select Where( :PairedGroup == PairedGroupList[i] );
	dtTemp = dt &amp;lt;&amp;lt; Subset( Invisible, Selected Rows );
	For( j = 1, j &amp;lt; N Rows( dtTemp ), j++,
		If( dtTemp:item[j] != dtTemp:item[j + 1],
			Print(dtTemp:path[j]);
			If(j + 1 == N Rows( dtTemp ),
				Print(dtTemp:path[j + 1]);
			)
		)
	);
	Close( dtTemp, no save );
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For example here you wouldn't loop over the last value, but check if the next value would be last, if it would be then print that also (if you did printthe current rows one).&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 22:25:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595235#M79893</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-01-30T22:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595291#M79899</link>
      <description>&lt;P&gt;Hi Ressel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried your solution, indeed it printed&amp;nbsp;&lt;SPAN&gt;"file path6" twice as you mentioned. Another problem i saw is when i purposely changed row 5 item value from 5 to 7 in order to have 2 identical rows, it's printed the last row ("file path 6"). Is there any way to avoid that? I'm seeing alternative for loop from jthi also have same issue.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nthai_0-1675138466871.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49661iE7F307B60DA88623/image-size/medium?v=v2&amp;amp;px=400" role="button" title="nthai_0-1675138466871.png" alt="nthai_0-1675138466871.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nthai_1-1675138484787.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49662i912BBD4EF5834BE9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="nthai_1-1675138484787.png" alt="nthai_1-1675138484787.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 04:44:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595291#M79899</guid>
      <dc:creator>nthai</dc:creator>
      <dc:date>2023-01-31T04:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595297#M79901</link>
      <description>&lt;P&gt;Hi jthi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for such a great answer with 3 different options. One of side note is i have to remove "1" from rows_to_open1 variable in order to make the code running. If you can correct this typo for future reference, that would be great!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other than that, i have a question related to your answer. What is the purpose of value "1" in each of Col Sum,&amp;nbsp;Col Cumulative Sum and&amp;nbsp;Col Max(Col Sum? And i don't get why we can sum character value from columns g1 and g2?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 04:55:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595297#M79901</guid>
      <dc:creator>nthai</dc:creator>
      <dc:date>2023-01-31T04:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595300#M79902</link>
      <description>&lt;P&gt;Edited my message to rename old variable. We aren't adding up character columns, we are using them from grouping (&amp;lt;byVar&amp;gt;). And we use 1 so we have something that will increase by 1 for each row in the group. It might be a good idea to create different types of formulas by using those functions to make it easier to understand how they work, scripting index also provides some examples.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/17.0/#page/jmp/statistical-functions-2.shtml?os=win&amp;amp;source=application#ww4579093" target="_blank" rel="noopener"&gt;Col Sum(name,&amp;lt;By var, ...&amp;gt;)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 06:16:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595300#M79902</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-01-31T06:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595306#M79903</link>
      <description>&lt;P&gt;Thank you jthi! One last question, how am i supposed to further modify formula to ignore if those columns g1, g2 and i only have 1 combination of valid file?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nthai_0-1675147621046.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49663i60BDD91CE7FA8EC7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="nthai_0-1675147621046.png" alt="nthai_0-1675147621046.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 06:47:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595306#M79903</guid>
      <dc:creator>nthai</dc:creator>
      <dc:date>2023-01-31T06:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595308#M79904</link>
      <description>&lt;P&gt;I manage to find one by create another column, "Unique":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;new_col = dt &amp;lt;&amp;lt; New Column("Unique", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(
	Col Sum(1, :g1, :g2); 
));



rows_to_open = dt &amp;lt;&amp;lt; Get Rows Where(:ValidFile == 1 &amp;amp; :Unique != 1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nthai_0-1675150798052.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49664iB555D8B15C99078E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="nthai_0-1675150798052.png" alt="nthai_0-1675150798052.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 07:44:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595308#M79904</guid>
      <dc:creator>nthai</dc:creator>
      <dc:date>2023-01-31T07:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595309#M79905</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;, neat, as always. Good learning, thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 07:45:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595309#M79905</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2023-01-31T07:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595310#M79906</link>
      <description>&lt;P&gt;You will have to modify the ValidFile calculations and possibly the row selection depending on how you build the ValidFile check.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;new_col = dt &amp;lt;&amp;lt; New Column("ValidFile", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(
	If(Col Sum(1, :g1, :g2, :i) == 1 &amp;amp; Col Number(:i, :g1, :g2) &amp;gt; 1,
		1
	,
		0
	);
));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jan 2023 07:48:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595310#M79906</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-01-31T07:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595425#M79917</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;, I just want to ask a few questions with regards to the last part of the code, i.e., I don't understand it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;file_list = {};
For Each({file_path}, filepaths_to_open,
	Insert Into(file_list, Open(file_path));
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="jsl"&gt;file_list = {};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is an empty list. The loop will fill this up via the Insert Into(file_list, Open(file_path)). Why can't one just use the list already contained in filepaths_to_open? Also, I don't understand how the Open(file_path) will insert something into the list. Isn't this just a function to open a file? How can at it all contribute to a list?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;{file_path}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This, I also don't understand. Is this just a placeholder for the actual filepaths?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe you have a reference explaining these things? Thank you very much already in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 11:51:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595425#M79917</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2023-01-31T11:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595508#M79922</link>
      <description>&lt;P&gt;I think those are easiest to understand by writing a demo script ( I modified For Each a bit to add idx, it might make it a bit easier to understand how it works)&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);

filepaths_to_open = {"$SAMPLE_DATA/Big Class.jmp", "$SAMPLE_DATA/Probe.jmp", "$SAMPLE_DATA/Iris.jmp"};
show(filepaths_to_open);
file_list = {};
show(file_list);
For Each({file_path, idx}, filepaths_to_open,
	show(idx, file_path);
	Insert Into(file_list, Open(file_path));
	show(file_list);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I use file_list to collect the references to the data tables which are opened (I don't need the filepaths as I already have them in the filepaths_to_open, but I don't have references)&lt;/LI&gt;
&lt;LI&gt;Open(file_path) will return a reference to the opened file and Insert Into will then add that reference to the file_list.&lt;/LI&gt;
&lt;LI&gt;The {filepath} comes from how &lt;A href="https://www.jmp.com/support/help/en/17.0/#page/jmp/conditional-and-logical-functions.shtml?os=win&amp;amp;source=application#ww10169967" target="_blank" rel="noopener"&gt;For Each function&lt;/A&gt; should be used. Basically it will loop over filepaths_to_open and will return each element (one by one) in file_path variable.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;filepaths_to_open = {"$SAMPLE_DATA/Big Class.jmp", "$SAMPLE_DATA/Probe.jmp", "$SAMPLE_DATA/Iris.jmp"};
file_list = {};
idx = 1;
file_path = "$SAMPLE_DATA/Big Class.jmp";
file_list = {DataTable("Big Class")};
idx = 2;
file_path = "$SAMPLE_DATA/Probe.jmp";
file_list = {DataTable("Big Class"), DataTable("Probe")};
idx = 3;
file_path = "$SAMPLE_DATA/Iris.jmp";
file_list = {DataTable("Big Class"), DataTable("Probe"), DataTable("Iris")};&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hopefully answer some of the questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 15:38:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/595508#M79922</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-01-31T15:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through rows from groups created by 2 columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/597334#M80090</link>
      <description>&lt;P&gt;Yes, that was actually very useful. The file_list variable was confusing, since it is not strictly needed to open to the files (but; I take it; that it is useful later on when closing all files again (?), for example, or some other manipulation). I have to admit that it also took me some time to wrap my head around the "file_path" variable, which is assigned to a different file path at every iteration, and that it doesn't matter what it is called. (In my head, I just interpret it now as a vehicle that picks one file path after the other from the filepaths_to_open list and lets the user do "something" with it.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you! Every week a tiny growth of knowledge is better that none at all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.s.: The below I was only able to write based on my understanding of your explanations. Again, very useful.&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 );

filepaths_to_open = {"$SAMPLE_DATA/Big Class.jmp", "$SAMPLE_DATA/Probe.jmp", "$SAMPLE_DATA/Iris.jmp"};

For Each( {file_path}, filepaths_to_open, Open( file_path ) );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 19:26:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-through-rows-from-groups-created-by-2-columns/m-p/597334#M80090</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2023-02-05T19:26:49Z</dc:date>
    </item>
  </channel>
</rss>

