<?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: rename columns in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/rename-columns/m-p/2932#M2932</link>
    <description>It worked for me, but I could reproduce the same error with another file I tried. I have edited the script above: char() is used to avoid that concat fails for numeric column names. And I changed the counter i to j because the forum sometimes refuse to show i within square brackets (at least my browser did not show the names&lt;J&gt; properly). &lt;BR /&gt;&lt;BR /&gt;Now it should be complete. At least it works as expected for me with a range of text files (JMP9 for Mac).&lt;/J&gt;</description>
    <pubDate>Fri, 11 Feb 2011 14:27:49 GMT</pubDate>
    <dc:creator>ms</dc:creator>
    <dc:date>2011-02-11T14:27:49Z</dc:date>
    <item>
      <title>rename columns</title>
      <link>https://community.jmp.com/t5/Discussions/rename-columns/m-p/2929#M2929</link>
      <description>I am creating a script that will import a .txt file and do some manipulation.  I want the column names to be a concatenation of rows 1 and 2.  In other words, on row 1 I have things like "length" and "width," on row 2 I have things like "meters" and "centimeters," and on rows 3 through x I have the values.  So I want to concat "length" with "meters" and make it the column name for column one, with all the data values starting on the new row 1.&lt;BR /&gt;&lt;BR /&gt;Any pointers on how to get started or suggestions of some things that might be helpful?&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Thu, 10 Feb 2011 19:53:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/rename-columns/m-p/2929#M2929</guid>
      <dc:creator />
      <dc:date>2011-02-10T19:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: rename columns</title>
      <link>https://community.jmp.com/t5/Discussions/rename-columns/m-p/2930#M2930</link>
      <description>&lt;P&gt;There are probably many ways this can be scripted. Here is one example using the different import text options. A tab delimited file is assumed here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are probably many ways this can be scripted. Here is one example using the different import text options. A tab delimited file is assumed here.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;[PRE]&lt;BR /&gt;//Open only first two rows&lt;BR /&gt;dt = Open(&lt;BR /&gt;&amp;nbsp;"path/file.txt",&lt;BR /&gt;&amp;nbsp;Import Settings(&lt;BR /&gt;&amp;nbsp;&amp;nbsp;End Of Field( Tab ),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;Labels( 1 ),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;Column Names Start( 1 ),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;Data Starts( 2 ),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;Lines To Read( 1 ), &lt;BR /&gt;&amp;nbsp;)&lt;BR /&gt;);&lt;BR /&gt;// Create a list of new column names&lt;BR /&gt;names = {};&lt;BR /&gt;For( j = 1, j &amp;lt;= N Col( dt ), j++,&lt;BR /&gt;&amp;nbsp;Insert Into( names, Column( j ) &amp;lt;&amp;lt; get name() || " " || Char(Column( j )[1]))&lt;BR /&gt;);&lt;BR /&gt;Close( dt, nosave );&lt;/P&gt;
&lt;P&gt;//Open again, include all data from row 3&amp;nbsp;&lt;BR /&gt;dt = Open(&lt;BR /&gt;&amp;nbsp;"path/file.txt",&lt;BR /&gt;&amp;nbsp;Import Settings(&lt;BR /&gt;&amp;nbsp;&amp;nbsp;End Of Line( CRLF, CR, LF ),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;End Of Field( Tab ),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;Column Names Start( 1 ),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;Data Starts( 3 ),&lt;/P&gt;
&lt;P&gt;&amp;nbsp;)&lt;BR /&gt;);&lt;/P&gt;
&lt;P&gt;//Set column names&lt;BR /&gt;For( j = 1, j &amp;lt;= N Col( dt ), j++,&lt;BR /&gt;&amp;nbsp;Column( j ) &amp;lt;&amp;lt; set name( names[j]))&lt;BR /&gt;[/PRE]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 13:48:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/rename-columns/m-p/2930#M2930</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2017-10-06T13:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: rename columns</title>
      <link>https://community.jmp.com/t5/Discussions/rename-columns/m-p/2931#M2931</link>
      <description>&lt;P&gt;Thanks you very much. I think that's really close and I think I understand what you're doing. However, I'm getting this error when I try to implement it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;::names = {};
For( ::i = 1, ::i &amp;lt;= N Col( ::dt ), ::i++,
	Insert Into(
		::names,
		Column( ::i ) &amp;lt;&amp;lt; get name ||  /*###*/" " ||  /*###*/Column( ::i )[1] /*###*/
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Any ideas? &amp;nbsp;I basically took your script and changed some of the import proferences. &amp;nbsp;Other than that, it's the same.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 12:36:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/rename-columns/m-p/2931#M2931</guid>
      <dc:creator />
      <dc:date>2017-10-06T12:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: rename columns</title>
      <link>https://community.jmp.com/t5/Discussions/rename-columns/m-p/2932#M2932</link>
      <description>It worked for me, but I could reproduce the same error with another file I tried. I have edited the script above: char() is used to avoid that concat fails for numeric column names. And I changed the counter i to j because the forum sometimes refuse to show i within square brackets (at least my browser did not show the names&lt;J&gt; properly). &lt;BR /&gt;&lt;BR /&gt;Now it should be complete. At least it works as expected for me with a range of text files (JMP9 for Mac).&lt;/J&gt;</description>
      <pubDate>Fri, 11 Feb 2011 14:27:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/rename-columns/m-p/2932#M2932</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2011-02-11T14:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: rename columns</title>
      <link>https://community.jmp.com/t5/Discussions/rename-columns/m-p/2933#M2933</link>
      <description>That worked!  Thank you very much!</description>
      <pubDate>Fri, 11 Feb 2011 18:23:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/rename-columns/m-p/2933#M2933</guid>
      <dc:creator />
      <dc:date>2011-02-11T18:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: rename columns</title>
      <link>https://community.jmp.com/t5/Discussions/rename-columns/m-p/2934#M2934</link>
      <description>FWIW I avoid using j as a looping variable, because it's a JSL matrix function!&lt;BR /&gt;&lt;BR /&gt;J(nrows, &lt;NCOLS&gt;, &lt;VALUE&gt;)&lt;BR /&gt;Function: Creates a matrix of identical values.&lt;BR /&gt;Returns: The matrix.&lt;BR /&gt;Arguments: &lt;BR /&gt;nrows Number of rows in matrix. If ncols is not specified, nrows is also used as ncols.&lt;BR /&gt;ncols Number of columns in matrix.&lt;BR /&gt;value The value used to populate the matrix. If value is not specified, 1 is used.&lt;BR /&gt;&lt;BR /&gt;j will work as a variable, but I tend to use i, k, m, n, etc.&lt;/VALUE&gt;&lt;/NCOLS&gt;</description>
      <pubDate>Fri, 11 Feb 2011 19:26:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/rename-columns/m-p/2934#M2934</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2011-02-11T19:26:05Z</dc:date>
    </item>
  </channel>
</rss>

