<?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: Unexpected error during script in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283740#M54818</link>
    <description>Fantastic. Thanks for the feedback. I had not considered that approach.&lt;BR /&gt;&lt;BR /&gt;Best,&lt;BR /&gt;&lt;BR /&gt;Sebastien</description>
    <pubDate>Sun, 02 Aug 2020 15:44:52 GMT</pubDate>
    <dc:creator>Sburel</dc:creator>
    <dc:date>2020-08-02T15:44:52Z</dc:date>
    <item>
      <title>Unexpected error during script</title>
      <link>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283673#M54808</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm writing a script to deconvolute a json file.&lt;/P&gt;&lt;P&gt;Once in jmp, the resulting table is composed of groups of columns&amp;nbsp; labelled such as study.xyz, study.cro, groups.xyz, groups.id, test.xyz, test.name,...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a series of tables for each of the groups such as study/groups/test.&lt;/P&gt;&lt;P&gt;I have a script that does that well when each subset is handle separately but for some reasons it stops creating the subset table when it moves to the next group.&lt;/P&gt;&lt;P&gt;I can move around the order in which those groups are processed and the first group to be 'subseted' for well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In other words, if I try to subset 'study' first, then 'groups' is not processed&lt;/P&gt;&lt;P&gt;If I move the script portion dedicated to 'groups' in first position, it get processed&amp;nbsp; but then 'study' does not.&lt;/P&gt;&lt;P&gt;I'm baffled. Any suggestions would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sebastien&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;		try(data table("P0_json")&amp;lt;&amp;lt;close window);
				try(data table("study")&amp;lt;&amp;lt;close window);
				try(data table("groups")&amp;lt;&amp;lt;close window);
		New Table( "P0_json",
	Add Rows( 16 ),

	New Column( "groups.group_id",
		Character,
		"Nominal",
		Set Values(
			{"A", "B", "C", "D", "E", "F", "G", "H", "A", "B", "C", "D", "E", "F",
			"G", "H"}
		)
	),
	New Column( "groups.strain",
		Character,
		"Nominal",
		Set Values(
			{"C57BL/6", "C57BL/6", "C57BL/6", "C57BL/6", "C57BL/6", "C57BL/6",
			"C57BL/6", "C57BL/6", "C57BL/6", "C57BL/6", "C57BL/6", "C57BL/6",
			"C57BL/6", "C57BL/6", "C57BL/6", "C57BL/6"}
		)
	),
	New Column( "groups.study_id",
		Character,
		"Nominal",
		Set Values(
			{"ELN-19-0587", "ELN-19-0587", "ELN-19-0587", "ELN-19-0587",
			"ELN-19-0587", "ELN-19-0587", "ELN-19-0587", "ELN-19-0587",
			"ELN-19-0588", "ELN-19-0588", "ELN-19-0588", "ELN-19-0588",
			"ELN-19-0588", "ELN-19-0588", "ELN-19-0588", "ELN-19-0588"}
		)
	),
	New Column( "study.investigator_study_id",
		Character,
		"Nominal",
		Set Values(
			{"NT200109", "NT191209", "", "", "", "", "", "", "", "", "", "", "", "",
			"", ""}
		)
	),
	New Column( "study.cro",
		Character,
		"Nominal",
		Set Values(
			{"XYZ", "XYZ", "", "", "", "", "", "", "", "", "", "", "", "", "",
			""}
		)
	)
);
//create study subset	
json =  Data Table("P0_json");
json&amp;lt;&amp;lt; clear column selection();
json &amp;lt;&amp;lt; select all rows;
			
tab = "study.";
nm="study";
Col_List = json &amp;lt;&amp;lt; Get Column Names( "String" );

For( i = 1, i &amp;lt;= N Items( Col_List ), i++,
	If( Contains( Col_List[i], tab ),
		Column( Col_List[i] ) &amp;lt;&amp;lt; Set Selected( 1 )
	)
);		

json&amp;lt;&amp;lt; Subset(
	Output Table( nm ),
	Selected Rows( 1 ),
	Selected columns only( 1 )
);
Data Table( nm ) &amp;lt;&amp;lt; select where( :study.cro == "" ) &amp;lt;&amp;lt; delete rows;

col = Data Table( nm )  &amp;lt;&amp;lt; get column names( string );
nc = N Items( col );
For( i = 1, i &amp;lt;= nc, i++,
	If( Contains( col[i], tab ),
	show(col[i]);
		column(col[i]) &amp;lt;&amp;lt; set name(munger(col[i],1,tab,""))
	)
);		

//create group subset		
//json =  Data Table("P0_json");		
json&amp;lt;&amp;lt; clear column selection();
json &amp;lt;&amp;lt; select all rows;
tab = "groups.";
nm="groups";
//Col_list = json &amp;lt;&amp;lt; Get Column Names( "String" );

For( i = 1, i &amp;lt;= N Items( Col_List ), i++,
	If( Contains( Col_List[i], tab ),
		Column( Col_List[i] ) &amp;lt;&amp;lt; Set Selected( 1 )
	)
);

json&amp;lt;&amp;lt; Subset(
	Output Table( nm ),
	Selected Rows( 1 ),
	Selected columns only( 1 )
);
Data Table( tab ) &amp;lt;&amp;lt; select where( :groups.group_id == "" ) &amp;lt;&amp;lt; delete rows;

col = Data Table( nm )  &amp;lt;&amp;lt; get column names( string );
nc = N Items( col);
For( i = 1, i &amp;lt;= nc, i++,
	If( Contains( col[i], tab ),
	show(col[i]);
		column(col[i]) &amp;lt;&amp;lt; set name(munger(col[i],1,tab,""))
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here's the scripts:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:33:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283673#M54808</guid>
      <dc:creator>Sburel</dc:creator>
      <dc:date>2023-06-09T23:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected error during script</title>
      <link>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283688#M54809</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I took a bit of time to debug but the main problem is that you were not pointing to the original table after the first subset. Also, you referred to column using your Col_List variable which can create odd results: I replace those calls with the more standard "Column (&amp;lt;data table&amp;gt;, &amp;lt;Col Num&amp;gt;)".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the updated script&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to Here (1);

try(data table("P0_json")&amp;lt;&amp;lt;close window);
				try(data table("study")&amp;lt;&amp;lt;close window);
				try(data table("groups")&amp;lt;&amp;lt;close window);
		New Table( "P0_json",
	Add Rows( 16 ),

	New Column( "groups.group_id",
		Character,
		"Nominal",
		Set Values(
			{"A", "B", "C", "D", "E", "F", "G", "H", "A", "B", "C", "D", "E", "F",
			"G", "H"}
		)
	),
	New Column( "groups.strain",
		Character,
		"Nominal",
		Set Values(
			{"C57BL/6", "C57BL/6", "C57BL/6", "C57BL/6", "C57BL/6", "C57BL/6",
			"C57BL/6", "C57BL/6", "C57BL/6", "C57BL/6", "C57BL/6", "C57BL/6",
			"C57BL/6", "C57BL/6", "C57BL/6", "C57BL/6"}
		)
	),
	New Column( "groups.study_id",
		Character,
		"Nominal",
		Set Values(
			{"ELN-19-0587", "ELN-19-0587", "ELN-19-0587", "ELN-19-0587",
			"ELN-19-0587", "ELN-19-0587", "ELN-19-0587", "ELN-19-0587",
			"ELN-19-0588", "ELN-19-0588", "ELN-19-0588", "ELN-19-0588",
			"ELN-19-0588", "ELN-19-0588", "ELN-19-0588", "ELN-19-0588"}
		)
	),
	New Column( "study.investigator_study_id",
		Character,
		"Nominal",
		Set Values(
			{"NT200109", "NT191209", "", "", "", "", "", "", "", "", "", "", "", "",
			"", ""}
		)
	),
	New Column( "study.cro",
		Character,
		"Nominal",
		Set Values(
			{"XYZ", "XYZ", "", "", "", "", "", "", "", "", "", "", "", "", "",
			""}
		)
	)
);
//create study subset	
json =  Data Table("P0_json");
json&amp;lt;&amp;lt; clear column selection();
json &amp;lt;&amp;lt; select all rows;
			
tab = "study.";
nm="study";
Col_List = json &amp;lt;&amp;lt; Get Column Names( "String" );

For( i = 1, i &amp;lt;= N Items( Col_List ), i++,
	If( Contains( Col_List[i], tab ),
		Column( json, i ) &amp;lt;&amp;lt; Set Selected( 1 ) //Changed the column call to point directly at json
	)
);		

json&amp;lt;&amp;lt; Subset(
	Output Table( nm ),
	Selected Rows( 1 ),
	Selected columns only( 1 )
);

dts = Data Table (nm);   // Summary table is now a variable called dts
dts &amp;lt;&amp;lt; select where( :study.cro == "" ) &amp;lt;&amp;lt; delete rows;

col = dts  &amp;lt;&amp;lt; get column names( string );
nc = N Items( col );
For( i = 1, i &amp;lt;= nc, i++,
	If( Contains( col[i], tab ),
	show(col[i]);
		column(dts, i) &amp;lt;&amp;lt; set name(munger(col[i],1,tab,"")) // Changed the column call to point to nm
	)
);		

//create group subset		
	
json &amp;lt;&amp;lt; clear column selection();
json &amp;lt;&amp;lt; select all rows;
tab = "groups.";
nm="groups";


For( i = 1, i &amp;lt;= N Items( Col_List ), i++,
	If( Contains( Col_List[i], tab ),
		Column( json, i ) &amp;lt;&amp;lt; Set Selected( 1 ) //Changed the column call to point directly at json
	)
);

json&amp;lt;&amp;lt; Subset(
	Output Table( nm ),
	Selected Rows( 1 ),
	Selected columns only( 1 )
);

dts = Data Table (nm); // Summary table is now a variable called dts
dts &amp;lt;&amp;lt; select where( :groups.group_id == "" ) &amp;lt;&amp;lt; delete rows; // changed "tab" with "nm"

col = dts  &amp;lt;&amp;lt; get column names( string );
nc = N Items( col);
For( i = 1, i &amp;lt;= nc, i++,
	If( Contains( col[i], tab ),
	show(col[i]);
		column(dts, i) &amp;lt;&amp;lt; set name(munger(col[i],1,tab,"")) // Changed the column call to point to nm
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Aug 2020 05:27:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283688#M54809</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2020-08-02T05:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected error during script</title>
      <link>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283690#M54810</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;There are a few Comments that are no longer meaningful, please disregard.&lt;BR /&gt;&lt;BR /&gt;Best,&lt;BR /&gt;&lt;BR /&gt;TS</description>
      <pubDate>Sun, 02 Aug 2020 05:28:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283690#M54810</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2020-08-02T05:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected error during script</title>
      <link>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283713#M54811</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11634"&gt;@Thierry_S&lt;/a&gt;&amp;nbsp;has already answered your original question. Here's a different answer that might avoid writing any JSL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use the JSON Wizard to get the tables you need, assuming your data is similar to this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="One way to represent your data in JSON" style="width: 688px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25917iA9E74B347053F1FE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture0.png" alt="One way to represent your data in JSON" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;One way to represent your data in JSON&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Open in the wizard:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Guess and stack to get the first view" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25918i6BA4C4278D6B3432/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture1.PNG" alt="Guess and stack to get the first view" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Guess and stack to get the first view&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Remember to stack!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Choose what JSON tags generate rows in the JMP table" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25919iA760780647BBDDD6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture2.PNG" alt="Choose what JSON tags generate rows in the JMP table" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Choose what JSON tags generate rows in the JMP table&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Explanation: The wizard reads the JSON text, scanning for tags. Tags checked as &lt;EM&gt;row&lt;/EM&gt; cause a row to be added to the table. Tags checked as &lt;EM&gt;col&lt;/EM&gt; add columns.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Node&lt;/EM&gt; shows the nesting of the text in the JSON.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Select the columns you don't want (easy on the column headers at the bottom) then pick No Column" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25920i813B9D1D2C4F458C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture3.PNG" alt="Select the columns you don't want (easy on the column headers at the bottom) then pick No Column" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Select the columns you don't want (easy on the column headers at the bottom) then pick No Column&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can select columns in the table preview, or do them one at a time in the GUI above the preview, or select them in the &lt;EM&gt;node&lt;/EM&gt; tree. The No Column is applied to all selected columns.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="At this point you might also uncheck Groups as a row generator. I forgot, and it made no difference this time. Depends on the JSON organization." style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25921iC17EC69E7642A736/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture4.PNG" alt="At this point you might also uncheck Groups as a row generator. I forgot, and it made no difference this time. Depends on the JSON organization." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;At this point you might also uncheck Groups as a row generator. I forgot, and it made no difference this time. Depends on the JSON organization.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Click OK&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="The resulting table's Source script can be re-run to open the table again" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25922i4120617DF30D2D5B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture5.PNG" alt="The resulting table's Source script can be re-run to open the table again" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;The resulting table's Source script can be re-run to open the table again&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Repeat for the other table&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Repeat the process to get the other table. Uncheck the study row to remove a blank row from the JMP table." style="width: 632px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25923i832751EA909DD663/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture6.PNG" alt="Repeat the process to get the other table. Uncheck the study row to remove a blank row from the JMP table." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Repeat the process to get the other table. Uncheck the study row to remove a blank row from the JMP table.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The JSON I used is attached, yours is probably a little different, so the steps may be a little different. You can also rename the columns (Column Name field) but I think they are already what you want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Aug 2020 11:31:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283713#M54811</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2020-08-02T11:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected error during script</title>
      <link>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283740#M54818</link>
      <description>Fantastic. Thanks for the feedback. I had not considered that approach.&lt;BR /&gt;&lt;BR /&gt;Best,&lt;BR /&gt;&lt;BR /&gt;Sebastien</description>
      <pubDate>Sun, 02 Aug 2020 15:44:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283740#M54818</guid>
      <dc:creator>Sburel</dc:creator>
      <dc:date>2020-08-02T15:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected error during script</title>
      <link>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283741#M54819</link>
      <description>This could also be a solution, but I was using the script to avoid having the user go through the wizard.&lt;BR /&gt;&lt;BR /&gt;Thanks a lot for the detailed explanation,&lt;BR /&gt;&lt;BR /&gt;Sebastien</description>
      <pubDate>Sun, 02 Aug 2020 15:49:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283741#M54819</guid>
      <dc:creator>Sburel</dc:creator>
      <dc:date>2020-08-02T15:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected error during script</title>
      <link>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283745#M54820</link>
      <description>&lt;P&gt;Save the script from the wizard.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Aug 2020 16:56:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Unexpected-error-during-script/m-p/283745#M54820</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2020-08-02T16:56:57Z</dc:date>
    </item>
  </channel>
</rss>

