<?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 create a script to import xls to jmp in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/how-to-create-a-script-to-import-xls-to-jmp/m-p/276781#M53739</link>
    <description>&lt;P&gt;As both txNelson and Ian mentioned, your data table does not have a really good format for a statistical analysis, however this is unfortunately quite often the case in industry, especially when spreadsheet tools are mainly used. Statistical data should be in columns and rows in a rectangular form whenever possible. Otherwise you need to specify each cell for the calculation instead of using vectors and matrices, which would be much more efficient. That's why txNelson imported the sheet twice and extracted the information, as Ian did in a similar fasion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some time ago I had a discovery presentation about tips for importing data from Excel I believe still holds:&amp;nbsp;&lt;A href="https://community.jmp.com/t5/Discovery-Summit-Europe-2016/Getting-around-common-pitfalls-working-with-Excel-data-in-JMP/ta-p/23525" target="_blank" rel="noopener"&gt;Getting-around-common-pitfalls-working-with-Excel-data-in-JMP (2016 JMP Discovery Summit Europe)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As well wrote some blogs about Importing from Excel. Different cases than yours but maybe useful for other situations:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.jmp.com/t5/forums/searchpage/tab/message?advanced=false&amp;amp;allow_punctuation=false&amp;amp;filter=location&amp;amp;location=blog-board:mdemel-blog&amp;amp;q=Excel" target="_blank" rel="noopener"&gt;Blogs from Martin about Excel and JMP&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Jul 2020 12:56:40 GMT</pubDate>
    <dc:creator>martindemel</dc:creator>
    <dc:date>2020-07-03T12:56:40Z</dc:date>
    <item>
      <title>how to create a script to import xls to jmp</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-create-a-script-to-import-xls-to-jmp/m-p/276633#M53685</link>
      <description>&lt;P&gt;i have a problem about import xls file to jmp using script&lt;/P&gt;&lt;P&gt;i want to import this file using row "7" as header and add new column "Lot id" fill data as B3 cell data (B6C141-02B5) into new column&lt;/P&gt;&lt;P&gt;how can i do this&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alexching_1-1593676960423.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24959iF7D5796BBC086C9B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="alexching_1-1593676960423.png" alt="alexching_1-1593676960423.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:15:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-create-a-script-to-import-xls-to-jmp/m-p/276633#M53685</guid>
      <dc:creator>alexching</dc:creator>
      <dc:date>2023-06-10T23:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a script to import xls to jmp</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-create-a-script-to-import-xls-to-jmp/m-p/276635#M53686</link>
      <description>&lt;P&gt;Here is the script to input your data&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alexching.PNG" style="width: 969px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24960iF23753344EF0A6D6/image-size/large?v=v2&amp;amp;px=999" role="button" title="alexching.PNG" alt="alexching.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I used the JMP Excel Wizard to open the file interactively and then copied the Source script that JMP created to place into the script.&amp;nbsp; The script reads in the file twice.&amp;nbsp; First to read the data, and then the second time to read in the Lot ID.&amp;nbsp; I then just added the code to let you select the Excel file to import, and the JSL required to create the new Lot ID column.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

path = Pick File();
dt = Open(
	path,
	Worksheets( "Sheet1" ),
	Use for all sheets( 1 ),
	Concatenate Worksheets( 0 ),
	Create Concatenation Column( 0 ),
	Worksheet Settings(
		1,
		Has Column Headers( 1 ),
		Number of Rows in Headers( 7 ),
		Headers Start on Row( 6 ),
		Data Starts on Row( 13 ),
		Data Starts on Column( 1 ),
		Data Ends on Row( 0 ),
		Data Ends on Column( 0 ),
		Replicated Spanned Rows( 1 ),
		Replicated Spanned Headers( 0 ),
		Suppress Hidden Rows( 1 ),
		Suppress Hidden Columns( 1 ),
		Suppress Empty Columns( 1 ),
		Treat as Hierarchy( 0 ),
		Multiple Series Stack( 0 ),
		Import Cell Colors( 0 ),
		Limit Column Detect( 0 ),
		Column Separator String( "-" )
	)
);

dtLotID = Open(
	path,
	Worksheets( "Sheet1" ),
	Use for all sheets( 1 ),
	Concatenate Worksheets( 0 ),
	Create Concatenation Column( 0 ),
	Worksheet Settings(
		1,
		Has Column Headers( 0 ),
		Number of Rows in Headers( 7 ),
		Headers Start on Row( 6 ),
		Data Starts on Row( 3 ),
		Data Starts on Column( 1 ),
		Data Ends on Row( 0 ),
		Data Ends on Column( 0 ),
		Replicated Spanned Rows( 1 ),
		Replicated Spanned Headers( 0 ),
		Suppress Hidden Rows( 1 ),
		Suppress Hidden Columns( 1 ),
		Suppress Empty Columns( 1 ),
		Treat as Hierarchy( 0 ),
		Multiple Series Stack( 0 ),
		Import Cell Colors( 0 ),
		Limit Column Detect( 0 ),
		Column Separator String( "-" )
	)
);

lotID = dtLotID:Column 2[1];
close(dtLotID, nosave );

dt &amp;lt;&amp;lt; New Column("Lot ID", Character, set each value(lotID));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jul 2020 10:01:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-create-a-script-to-import-xls-to-jmp/m-p/276635#M53686</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-07-02T10:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a script to import xls to jmp</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-create-a-script-to-import-xls-to-jmp/m-p/276636#M53687</link>
      <description>&lt;P&gt;I think you will need to know a little JSL, and this should get you started. The 'best' approach will be determined by what you can (and can't) assume about the structure of the data beyond the example you have given.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code is not at all robust, and assumes your file is in the 'downloads' folder. If you look at 'Help &amp;gt; Books &amp;gt; Scripting Guide' you can probably figure out what it's doing (depending on how much coding experience you have).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);

dt = Open("$DOWNLOADS/test_import.xlsx");

lid = Column(dt, 2)[2];
colNames = {};
InsertInto(colNames, Column(dt, 1)[11]);
InsertInto(colNames, Column(dt, 2)[11]);
InsertInto(colNames, Column(dt, 3)[7]);
InsertInto(colNames, Column(dt, 4)[7]);
InsertInto(colNames, Column(dt, 5)[7]);
InsertInto(colNames, Column(dt, 6)[7]);
InsertInto(colNames, Column(dt, 1)[2]);

dt &amp;lt;&amp;lt; deleteRows(1::11);
for(c=1, c&amp;lt;=NItems(colNames), c++, Column(dt, c) &amp;lt;&amp;lt; setName(colNames[c]));
Column(dt, colNames[NItems(colNames)]) &amp;lt;&amp;lt; setValues(Repeat(lid, NRows(dt)));
dt &amp;lt;&amp;lt; setName("Data for lot "||lid);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jul 2020 10:52:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-create-a-script-to-import-xls-to-jmp/m-p/276636#M53687</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2020-07-02T10:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a script to import xls to jmp</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-create-a-script-to-import-xls-to-jmp/m-p/276781#M53739</link>
      <description>&lt;P&gt;As both txNelson and Ian mentioned, your data table does not have a really good format for a statistical analysis, however this is unfortunately quite often the case in industry, especially when spreadsheet tools are mainly used. Statistical data should be in columns and rows in a rectangular form whenever possible. Otherwise you need to specify each cell for the calculation instead of using vectors and matrices, which would be much more efficient. That's why txNelson imported the sheet twice and extracted the information, as Ian did in a similar fasion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some time ago I had a discovery presentation about tips for importing data from Excel I believe still holds:&amp;nbsp;&lt;A href="https://community.jmp.com/t5/Discovery-Summit-Europe-2016/Getting-around-common-pitfalls-working-with-Excel-data-in-JMP/ta-p/23525" target="_blank" rel="noopener"&gt;Getting-around-common-pitfalls-working-with-Excel-data-in-JMP (2016 JMP Discovery Summit Europe)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As well wrote some blogs about Importing from Excel. Different cases than yours but maybe useful for other situations:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.jmp.com/t5/forums/searchpage/tab/message?advanced=false&amp;amp;allow_punctuation=false&amp;amp;filter=location&amp;amp;location=blog-board:mdemel-blog&amp;amp;q=Excel" target="_blank" rel="noopener"&gt;Blogs from Martin about Excel and JMP&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jul 2020 12:56:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-create-a-script-to-import-xls-to-jmp/m-p/276781#M53739</guid>
      <dc:creator>martindemel</dc:creator>
      <dc:date>2020-07-03T12:56:40Z</dc:date>
    </item>
  </channel>
</rss>

