<?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: Possible to preserve leading white space in column names for copied table scripts? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Possible-to-preserve-leading-white-space-in-column-names-for/m-p/561797#M77487</link>
    <description>&lt;P&gt;Even though I would never use leading whitespace in column name (I would also avoid most of special characters), in this case I would say it should work, as it seems to be valid column name in JMP.&amp;nbsp; I would say this is a bug with New Column.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(1),
	New Column("A", Numeric, "Continuous", Format("Best", 12), Set Values([1])),
	New Column(" A", Numeric, "Continuous", Format("Best", 12), Set Values([2]))
);
wait(1);
Column(dt, 2) &amp;lt;&amp;lt; Set Name(" A");
wait(1);
dt &amp;lt;&amp;lt; New Column("  A");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;Only "quick" workaround that comes to my mind is to add &amp;lt;&amp;lt; Set Name to New Table script, but I'm not sure if this would trigger before groupings are done&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(1),
	New Column("A", Numeric, "Continuous", Format("Best", 12), Set Values([1])),
	New Column(" A", Numeric, "Continuous", Format("Best", 12), Set Values([2]), &amp;lt;&amp;lt; Set Name(" A"))
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so you would first have to get the script to clipboard and then get it as a text and modify that before running it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is very quick example which works with this one example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

str = JSL Quote(dt = New Table("Untitled",
	Add Rows(1),
	New Column("A", Numeric, "Continuous", Format("Best", 12), Set Values([1])),
	New Column(" A", Numeric, "Continuous", Format("Best", 12), Set Values([2]))
));

new_lines = {};
For Each({line}, Words(str, "\!N"),
	If(Starts With(Trim Whitespace(line), "New Column("),
		// get column name
		col_name = Regex(Trim Whitespace(line), "^New Column\(\!"(.+?)\!",\s", "\1");
		// add set name
		last_idx = Contains(line, ")", -1);
		new_line = Left(line, last_idx - 1) || ", &amp;lt;&amp;lt; Set Name(\!"" || col_name ||"\!")),";
		Insert Into(new_lines, new_line);
	,
		Insert Into(new_lines, line);
	);
);

old_dt = Eval(Parse(str));
new_dt = Eval(Parse(Concat Items(new_lines, "\!N")));

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 28 Oct 2022 13:29:30 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2022-10-28T13:29:30Z</dc:date>
    <item>
      <title>Possible to preserve leading white space in column names for copied table scripts?</title>
      <link>https://community.jmp.com/t5/Discussions/Possible-to-preserve-leading-white-space-in-column-names-for/m-p/561770#M77486</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Problem&lt;/STRONG&gt;: I run a script to load data from a database. I delete all formulas from the data table. I copy the table script using the red triangle menu. I paste the table script into a script window. I run the script. The table resulting from the table script has different column grouping and throws the columns around (see screenshot showing Columns panel from original table and table as created by table script side by side. See also files attached for reference).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ressel_0-1666962417306.png" style="width: 482px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/46693i54085CF1D304C8CC/image-dimensions/482x112?v=v2" width="482" height="112" role="button" title="Ressel_0-1666962417306.png" alt="Ressel_0-1666962417306.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I initially suspected that this wass due to the table script not preserving leading whitespace in column names, but as the screenshot below shows, the leading whitespaces are indeed part of the table script, they are just not considered in the table re-created from the table script.&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="Ressel_0-1666962930002.png" style="width: 726px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/46695i67744949CB43970C/image-dimensions/726x442?v=v2" width="726" height="442" role="button" title="Ressel_0-1666962930002.png" alt="Ressel_0-1666962930002.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Is there some way to really recreate the original data table, including white spaces in column names&lt;/STRONG&gt; or is that generally a poor scripting strategy?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:56:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Possible-to-preserve-leading-white-space-in-column-names-for/m-p/561770#M77486</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2023-06-10T23:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Possible to preserve leading white space in column names for copied table scripts?</title>
      <link>https://community.jmp.com/t5/Discussions/Possible-to-preserve-leading-white-space-in-column-names-for/m-p/561797#M77487</link>
      <description>&lt;P&gt;Even though I would never use leading whitespace in column name (I would also avoid most of special characters), in this case I would say it should work, as it seems to be valid column name in JMP.&amp;nbsp; I would say this is a bug with New Column.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(1),
	New Column("A", Numeric, "Continuous", Format("Best", 12), Set Values([1])),
	New Column(" A", Numeric, "Continuous", Format("Best", 12), Set Values([2]))
);
wait(1);
Column(dt, 2) &amp;lt;&amp;lt; Set Name(" A");
wait(1);
dt &amp;lt;&amp;lt; New Column("  A");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;Only "quick" workaround that comes to my mind is to add &amp;lt;&amp;lt; Set Name to New Table script, but I'm not sure if this would trigger before groupings are done&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(1),
	New Column("A", Numeric, "Continuous", Format("Best", 12), Set Values([1])),
	New Column(" A", Numeric, "Continuous", Format("Best", 12), Set Values([2]), &amp;lt;&amp;lt; Set Name(" A"))
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so you would first have to get the script to clipboard and then get it as a text and modify that before running it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is very quick example which works with this one example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

str = JSL Quote(dt = New Table("Untitled",
	Add Rows(1),
	New Column("A", Numeric, "Continuous", Format("Best", 12), Set Values([1])),
	New Column(" A", Numeric, "Continuous", Format("Best", 12), Set Values([2]))
));

new_lines = {};
For Each({line}, Words(str, "\!N"),
	If(Starts With(Trim Whitespace(line), "New Column("),
		// get column name
		col_name = Regex(Trim Whitespace(line), "^New Column\(\!"(.+?)\!",\s", "\1");
		// add set name
		last_idx = Contains(line, ")", -1);
		new_line = Left(line, last_idx - 1) || ", &amp;lt;&amp;lt; Set Name(\!"" || col_name ||"\!")),";
		Insert Into(new_lines, new_line);
	,
		Insert Into(new_lines, line);
	);
);

old_dt = Eval(Parse(str));
new_dt = Eval(Parse(Concat Items(new_lines, "\!N")));

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Oct 2022 13:29:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Possible-to-preserve-leading-white-space-in-column-names-for/m-p/561797#M77487</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-10-28T13:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Possible to preserve leading white space in column names for copied table scripts?</title>
      <link>https://community.jmp.com/t5/Discussions/Possible-to-preserve-leading-white-space-in-column-names-for/m-p/561799#M77488</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;thanks. I was afraid that leading whitespace was bad practice. &lt;STRONG&gt;Any list this bug can or may be added to or reported?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Also, I think it is easier to rewrite my script to give different column names than to implement the workarounds suggested by you. (Labelled your response accidently as solution when I actually just tried to respond.) As always, thank you for your invaluable input and tireless efforts to educate other JMP users. This is extremely helpful.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 13:42:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Possible-to-preserve-leading-white-space-in-column-names-for/m-p/561799#M77488</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2022-10-28T13:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Possible to preserve leading white space in column names for copied table scripts?</title>
      <link>https://community.jmp.com/t5/Discussions/Possible-to-preserve-leading-white-space-in-column-names-for/m-p/561895#M77498</link>
      <description>&lt;P&gt;I have usually contacted jmp support with bugs. This post should be quite good example of the situation so remember to add link to this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is definitely (in my opinion) a good idea to rename the columns rather than try to manage some sort of weird workarounds. Those whitespaces could end up causing issues later anyway.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 16:31:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Possible-to-preserve-leading-white-space-in-column-names-for/m-p/561895#M77498</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-10-28T16:31:06Z</dc:date>
    </item>
  </channel>
</rss>

