<?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: Script: Remove prefix of string and output modified column to Excel file in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401748#M65269</link>
    <description>&lt;P&gt;Thanks for the response,&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11634"&gt;@Thierry_S&lt;/a&gt;&amp;nbsp;! I am currently trying your scriptlet out as well as some other things.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This may sound like a super simple thing for most, but I don't actually know what the best way to visualize output for debugging purposes when more than just a single-value variable is involved, i.e. how to pop out a single column into a new data table (using JSL only), or print the column to the log, or something like that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't remember, maybe I've done this before and am just drawing a blank, but I feel kind of silly for asking.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;</description>
    <pubDate>Fri, 16 Jul 2021 17:44:11 GMT</pubDate>
    <dc:creator>mostarr</dc:creator>
    <dc:date>2021-07-16T17:44:11Z</dc:date>
    <item>
      <title>Script: Remove prefix of string and output modified column to Excel file</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401069#M65208</link>
      <description>&lt;P&gt;Hi everyone. I have been following the advice at&amp;nbsp;&lt;LI-MESSAGE title="String parsing formula" uid="51077" url="https://community.jmp.com/t5/Discussions/String-parsing-formula/m-p/51077#U51077" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&amp;nbsp;and some other references for writing data to files, mostly applicable to chunk text files but I found the&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Save Excel File()&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;function in the Scripting Index. I don't know what the last parameter means/does? It isn't explained. That is to say,&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Separate Rows for Each Cell Statistic( 1 )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is this important? It doesn't write anything to any file in the location I have specified whether this parameter is present or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a rough outline of my script:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
c = Words(:ID, "_");
Write(c);
s = c[2] || "_" || c[3] || "_" || c[4] || "_" || c[5];
Write(s);
s &amp;lt;&amp;lt; Save Excel File(
	"$DOCUMENTS\temp.xlsx",
	Separate Rows for Each Cell Statistic( 1 )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So I'm trying to remove the prefix, and keep the remaining four "word blocks" plus their underscores, which I am adding back via string concatenation manually. See&amp;nbsp;&lt;LI-MESSAGE title="string and variable concatenation" uid="56308" url="https://community.jmp.com/t5/Discussions/string-and-variable-concatenation/m-p/56308#U56308" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;for string concatenation "||" reference.&lt;/P&gt;
&lt;P&gt;Anyway, no file shows up at $DOCUMENTS\temp.xlsx.&lt;/P&gt;
&lt;P&gt;Also the, um, what's it called, terminal, window, log, is giving me the error&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Subscript Range in access or evaluation of 'c[2]' , c[/*###*/2]&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and I don't know why. No strings or columns are output as a result of the Write() statements I have included.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So basically nothing is working as it should. Square one, I suppose!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know what tips you all can think up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:33:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401069#M65208</guid>
      <dc:creator>mostarr</dc:creator>
      <dc:date>2023-06-10T23:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: Script: Remove prefix of string and output modified column to Excel file</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401082#M65209</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;When dealing with strings, I tend to prefer to work with string specific functions (e.g. Substitute (), Munger (), Right (), Word());&lt;/P&gt;
&lt;P&gt;Hence, in your case, I would suggest the following formula to remove the first part of the IDS string including the first instance of the "_" character:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Substitute( :IDS, Word( 1, :IDS, "_" ) || "_", "" )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 19:13:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401082#M65209</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2021-07-14T19:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Script: Remove prefix of string and output modified column to Excel file</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401087#M65210</link>
      <description>&lt;P&gt;I think Save Excel file is a special case for Categorical Response Analysis Platform &lt;A href="https://www.jmp.com/support/help/en/15.2/#page/jmp/additional-categorical-platform-options.shtml?os=win&amp;amp;source=application&amp;amp;utm_source=helpmenu&amp;amp;utm_medium=application#ww998822" target="_blank" rel="noopener"&gt;Additional Categorical Platform Options&lt;/A&gt; . To save an datatable as excel file you can just use &amp;lt;&amp;lt; Save(path).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently you are trying to save just one string to a excel file, string created from the first row of datatable. Depending how and what you want to save, you have different options, below is one where the :ID column values are replaced with new values with the characters before first _ removed:&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);

dt = New Table("Untitled 2",
	Add Rows(3),
	Compress File When Saved(1),
	New Column("ID", Character, "Nominal", Set Values({"1_2_3_4_5_6", "2_3_4_5_6_7", "3_4_5_6_7_8"}))
);

Wait(1);

dt:ID &amp;lt;&amp;lt; Set Each Value(
	Substr(:ID, Contains(:ID, "_")+1)
);

dt  &amp;lt;&amp;lt; Save("$DOCUMENTS\test.xlsx");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You could also create new column with the new values which is most likely a better approach.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 19:14:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401087#M65210</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-07-14T19:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Script: Remove prefix of string and output modified column to Excel file</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401748#M65269</link>
      <description>&lt;P&gt;Thanks for the response,&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11634"&gt;@Thierry_S&lt;/a&gt;&amp;nbsp;! I am currently trying your scriptlet out as well as some other things.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This may sound like a super simple thing for most, but I don't actually know what the best way to visualize output for debugging purposes when more than just a single-value variable is involved, i.e. how to pop out a single column into a new data table (using JSL only), or print the column to the log, or something like that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't remember, maybe I've done this before and am just drawing a blank, but I feel kind of silly for asking.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 17:44:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401748#M65269</guid>
      <dc:creator>mostarr</dc:creator>
      <dc:date>2021-07-16T17:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Script: Remove prefix of string and output modified column to Excel file</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401801#M65270</link>
      <description>&lt;P&gt;Also, in general, if you have a function which accepts a parameter or variable, will passing in a column perform the function element-wise to the column?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 18:17:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401801#M65270</guid>
      <dc:creator>mostarr</dc:creator>
      <dc:date>2021-07-16T18:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Script: Remove prefix of string and output modified column to Excel file</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401851#M65276</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Also, in general, if you have a function which accepts a parameter or variable, will passing in a column perform the function element-wise to the column?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No. Usually if you need something evaluated for each row of a data table you will want to either create formula column in the data table or use the &lt;A href="https://www.jmp.com/support/help/en/16.0/jmp/conditional-and-logical-functions.shtml#ww4890947" target="_self"&gt;For Each Row()&lt;/A&gt; iterator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;JMP 16 introduced the &lt;A href="https://www.jmp.com/support/help/en/16.0/jmp/conditional-and-logical-functions.shtml#ww10169967" target="_self"&gt;For Each()&lt;/A&gt; function to iterate over JSL data structures:&lt;SPAN&gt; lists, associative arrays, or matrices.&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 21:13:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401851#M65276</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2021-07-16T21:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Script: Remove prefix of string and output modified column to Excel file</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401862#M65277</link>
      <description>&lt;P&gt;This is a great framework; the problem I have identified now is quite simple:&lt;/P&gt;&lt;P&gt;The table I am working with is a subset of rows of the full table. And when I go Column(:ID), it doesn't find the column, i.e.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;could not find column{3} in access or evaluation of 'Column' , Column/*###*/(dt:ID)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Which seems really simple but I don't know why. I thought it would be because I am using a subset of the rows, which I do need to do but I can find out if is the case by trying the script on the base table. One moment...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No it seems to be a problem on the full data table as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice for "finding" my column?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 22:55:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401862#M65277</guid>
      <dc:creator>mostarr</dc:creator>
      <dc:date>2021-07-16T22:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Script: Remove prefix of string and output modified column to Excel file</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401886#M65280</link>
      <description>&lt;P&gt;Add the data table pointer to the column function, make sure it is the table with the column.&lt;/P&gt;&lt;P&gt;Column(dt, :id)&lt;/P&gt;&lt;P&gt;it sounds like there might be multiple tables open, and JMP is trying to use the current table, which is not the one you want.&lt;/P&gt;&lt;P&gt;When you make the subset, you can get the table pointer for the new table:&lt;/P&gt;&lt;P&gt;dtSubset = dt&amp;lt;&amp;lt;subset(...);&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jul 2021 19:31:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Remove-prefix-of-string-and-output-modified-column-to/m-p/401886#M65280</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2021-07-17T19:31:16Z</dc:date>
    </item>
  </channel>
</rss>

