<?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: Set Column Data Type for JSON Panda Split in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Set-Column-Data-Type-for-JSON-Panda-Split/m-p/828083#M100981</link>
    <description>&lt;P&gt;I don't have proper example to test this out (JMP just crashes with my JSON example I quickly got) so I cannot test if there is a way to do it in JSON Wizard.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can convert just numeric values by checking values from the column first, and then convert them accordingly.&lt;/P&gt;
&lt;P&gt;One way of performing the conversion is to first check some values of the column and then convert if they are OK. Few options you could check&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Just check first value&lt;/LI&gt;
&lt;LI&gt;Check first and last value&lt;/LI&gt;
&lt;LI&gt;Check all values&lt;/LI&gt;
&lt;LI&gt;Check random subset of values&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Nowadays I would do the check using Num(&amp;lt;&amp;lt;Restrict) (earlier wasn't possible as it converted too much). If the value isn't missing (unless it was missing already before conversion) it should be valid to be changed to numeric -&amp;gt; change data type of column. I think you can also use InFormat() for checking the "best" match (might be even better than Num()).&lt;/P&gt;</description>
    <pubDate>Sat, 18 Jan 2025 06:40:07 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2025-01-18T06:40:07Z</dc:date>
    <item>
      <title>Set Column Data Type for JSON Panda Split</title>
      <link>https://community.jmp.com/t5/Discussions/Set-Column-Data-Type-for-JSON-Panda-Split/m-p/828050#M100977</link>
      <description>&lt;P&gt;I am using JSL to import a JSON file using a Panda Split format.&amp;nbsp; When I do this, all columns are imported as Character, when in practice they should be a combination of&amp;nbsp;Character and Numeric.&amp;nbsp; I can write a JSL script convert each to&amp;nbsp;Numeric, but this will also convert the&amp;nbsp;Character columns (and delete their data).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using JSL, can I detect if a Data Type should be&amp;nbsp;Character or Numeric and convert it accordingly?&amp;nbsp; Or is there a way to do this during the import step?&amp;nbsp; I do not know the columns for a specific file beforehand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JMP 18.1.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt_cols = dt &amp;lt;&amp;lt; Get Column Names();
For Each({col, i}, dt_cols,	
	Try(
		// No warning, just converts everything.
		As Column(dt, col) &amp;lt;&amp;lt; Data Type("Numeric");
		As Column(dt, col) &amp;lt;&amp;lt; Modeling Type( "Continuous" );
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Jan 2025 01:48:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-Column-Data-Type-for-JSON-Panda-Split/m-p/828050#M100977</guid>
      <dc:creator>robot</dc:creator>
      <dc:date>2025-01-18T01:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: Set Column Data Type for JSON Panda Split</title>
      <link>https://community.jmp.com/t5/Discussions/Set-Column-Data-Type-for-JSON-Panda-Split/m-p/828083#M100981</link>
      <description>&lt;P&gt;I don't have proper example to test this out (JMP just crashes with my JSON example I quickly got) so I cannot test if there is a way to do it in JSON Wizard.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can convert just numeric values by checking values from the column first, and then convert them accordingly.&lt;/P&gt;
&lt;P&gt;One way of performing the conversion is to first check some values of the column and then convert if they are OK. Few options you could check&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Just check first value&lt;/LI&gt;
&lt;LI&gt;Check first and last value&lt;/LI&gt;
&lt;LI&gt;Check all values&lt;/LI&gt;
&lt;LI&gt;Check random subset of values&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Nowadays I would do the check using Num(&amp;lt;&amp;lt;Restrict) (earlier wasn't possible as it converted too much). If the value isn't missing (unless it was missing already before conversion) it should be valid to be changed to numeric -&amp;gt; change data type of column. I think you can also use InFormat() for checking the "best" match (might be even better than Num()).&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2025 06:40:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-Column-Data-Type-for-JSON-Panda-Split/m-p/828083#M100981</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-01-18T06:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: Set Column Data Type for JSON Panda Split</title>
      <link>https://community.jmp.com/t5/Discussions/Set-Column-Data-Type-for-JSON-Panda-Split/m-p/828466#M101039</link>
      <description>&lt;P&gt;Yes, that works.&amp;nbsp;&amp;nbsp;Thanks Jarmo.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 18:03:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-Column-Data-Type-for-JSON-Panda-Split/m-p/828466#M101039</guid>
      <dc:creator>robot</dc:creator>
      <dc:date>2025-01-21T18:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Set Column Data Type for JSON Panda Split</title>
      <link>https://community.jmp.com/t5/Discussions/Set-Column-Data-Type-for-JSON-Panda-Split/m-p/828502#M101044</link>
      <description>&lt;P&gt;Here is a JSL implementation for reference:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rows_to_check_for_conversion = 100;

// Get column names.
dt_cols = dt &amp;lt;&amp;lt; Get Column Names();

// Change data types.
For Each( {c, i}, dt_cols, 
	
	non_missing_rows = dt &amp;lt;&amp;lt; Get Rows Where( !Is Missing( As Column( dt, c ) ) );
	
	row_check = 0;
	convert_to_number = 1;
	While( row_check &amp;lt; rows_to_check_for_conversion &amp;amp; row_check &amp;lt; N Items( non_missing_rows ) &amp;amp; convert_to_number == 1,
		row_check = row_check + 1;
		r = non_missing_rows[row_check];
		val = Num( dt:c[r] );
		If( Is Missing( val ),
			convert_to_number = 0
		);
	);
	
	If( convert_to_number == 1,
		As Column( dt, c ) &amp;lt;&amp;lt; Data Type( "Numeric" );
		As Column( dt, c ) &amp;lt;&amp;lt; Modeling Type( "Continuous" );
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Jan 2025 00:57:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-Column-Data-Type-for-JSON-Panda-Split/m-p/828502#M101044</guid>
      <dc:creator>robot</dc:creator>
      <dc:date>2025-01-22T00:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Set Column Data Type for JSON Panda Split</title>
      <link>https://community.jmp.com/t5/Discussions/Set-Column-Data-Type-for-JSON-Panda-Split/m-p/828575#M101052</link>
      <description>&lt;P&gt;Few changes which might be good to do: Use Column() instead of As Column() and check if adding &amp;lt;&amp;lt; Restrict into your Num() call is something you want to do (I have done it for my version of something like this).&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 06:46:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-Column-Data-Type-for-JSON-Panda-Split/m-p/828575#M101052</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-01-22T06:46:23Z</dc:date>
    </item>
  </channel>
</rss>

