<?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 read two rows from txt-file as column name in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/604278#M80714</link>
    <description>&lt;P&gt;Thank you very much for the support.&lt;BR /&gt;I prefer this JSL solution.&lt;/P&gt;&lt;P&gt;The multiple file import works fine too but adds an “_” to the header name.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mlo1_0-1677138490223.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50376iF4C44368E17D9B3A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mlo1_0-1677138490223.png" alt="mlo1_0-1677138490223.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Feb 2023 08:00:29 GMT</pubDate>
    <dc:creator>mlo1</dc:creator>
    <dc:date>2023-02-23T08:00:29Z</dc:date>
    <item>
      <title>How to read two rows from txt-file as column name</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/603939#M80693</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an option in JSL to read in the first two lines of a text file as a column header or&lt;BR /&gt;alternatively (and even better) the first as Column name and the second as the column property (Units)&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;Mirko&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="mlo1_0-1677085708791.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50362i611DB756D1178AE6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mlo1_0-1677085708791.png" alt="mlo1_0-1677085708791.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2742"&gt;@martindemel&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:34:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/603939#M80693</guid>
      <dc:creator>mlo1</dc:creator>
      <dc:date>2023-06-08T16:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to read two rows from txt-file as column name</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/604031#M80700</link>
      <description>&lt;P&gt;Craige's example below is a better solution, but this code might also be useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a little script that does the conversion you want&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Open(
	"&amp;lt;Path to BSP_jmp.TXT&amp;gt;",
	columns(
		New Column( "YYYY", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "MM/DD", Character, "Nominal" ),
		New Column( "DAY", Character, "Nominal" ),
		New Column( "hh:mm:ss", Numeric, "Continuous", Format( "h:m:s", 11, 0 ), Input Format( "h:m:s", 0 ) )
	)
);

// Add 2nd line text to Column Name
For( i = 1, i &amp;lt;= N Cols( dt ), i++,
	If( Column( dt, i ) &amp;lt;&amp;lt; get data type == "Character" &amp;amp; Column( dt, i )[1] != "",
		Column( dt, i ) &amp;lt;&amp;lt; set name( Column( dt, i ) &amp;lt;&amp;lt; get name || Column( dt, i )[1] )
	)
);

// Delete second name row
dt &amp;lt;&amp;lt; delete rows(1);

// Convert columns that are character but should be numeric, to numeric
For( i = 1, i &amp;lt;= N Cols( dt ), i++,
	If( Column( dt, i ) &amp;lt;&amp;lt; get data type == "Character" &amp;amp; Is Missing( Num( Column( dt, i )[1] ) ) != 1,
		Column( dt, i ) &amp;lt;&amp;lt; set data type( Numeric ) &amp;lt;&amp;lt; set modeling type( Continuous )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1677095169116.png" style="width: 870px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50367i57C263D5BF41037B/image-dimensions/870x161?v=v2" width="870" height="161" role="button" title="txnelson_0-1677095169116.png" alt="txnelson_0-1677095169116.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 23:44:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/604031#M80700</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-02-22T23:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to read two rows from txt-file as column name</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/604209#M80710</link>
      <description>&lt;P&gt;Multiple File Import can do it, even for a single file.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 562px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50372i442E340211125ACD/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 23:24:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/604209#M80710</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-02-22T23:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to read two rows from txt-file as column name</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/604278#M80714</link>
      <description>&lt;P&gt;Thank you very much for the support.&lt;BR /&gt;I prefer this JSL solution.&lt;/P&gt;&lt;P&gt;The multiple file import works fine too but adds an “_” to the header name.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mlo1_0-1677138490223.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50376iF4C44368E17D9B3A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mlo1_0-1677138490223.png" alt="mlo1_0-1677138490223.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 08:00:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/604278#M80714</guid>
      <dc:creator>mlo1</dc:creator>
      <dc:date>2023-02-23T08:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to read two rows from txt-file as column name</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/604280#M80715</link>
      <description>&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 08:19:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/604280#M80715</guid>
      <dc:creator>mlo1</dc:creator>
      <dc:date>2023-02-23T08:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to read two rows from txt-file as column name</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/604442#M80722</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dtlist = Multiple File Import(
	&amp;lt;&amp;lt;Set Folder( "Z:\" ),
	&amp;lt;&amp;lt;Set Name Filter( "BSP_JMP.txt" ),
	&amp;lt;&amp;lt;Set Name Enable( 1 ),
	&amp;lt;&amp;lt;Set CSV First Header Line( 1 ),
	&amp;lt;&amp;lt;Set CSV Number Of Header Lines( 2 ),
	&amp;lt;&amp;lt;Set CSV First Data Line( 3 )
) &amp;lt;&amp;lt; Import Data;

dt = dtlist[1];

namelist = dt &amp;lt;&amp;lt; getColumnNames();
// since the _ does not appear in the CSV file, you can use it to
// split the names and then rejoin them.
For Each( {c}, namelist, {txt, parts, newname, p1, p2},
	txt = c &amp;lt;&amp;lt; getname;
	parts = Words( txt, "_" );
	p1 = Trim( parts[1] );
	If( N Items( parts ) == 2,
		p2 = Trim( parts[2] );
		If( Contains( {"km", "m/min", "%", "deg/min", "um"}, p2 ), // identify real units
			c &amp;lt;&amp;lt; Set Property( "Units", Eval( p2 ) ); // and use units property
			newname = p1;
		, // else not real units
			newname = p1 || "&amp;lt;" || p2 || "&amp;gt;"; // make part of name
		);
	, // only one part? still need the rename to remove the trailing _
		newname = p1
	);
	c &amp;lt;&amp;lt; setname( newname );
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50387iD110CEF55129555B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.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>Thu, 23 Feb 2023 13:27:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/604442#M80722</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-02-23T13:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to read two rows from txt-file as column name</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/604564#M80733</link>
      <description>&lt;P&gt;You could use the multiple file import to do the import and use then a script to replace the "_" between the header lines in the column names with whatever you like. Just an idea.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 16:42:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-read-two-rows-from-txt-file-as-column-name/m-p/604564#M80733</guid>
      <dc:creator>martindemel</dc:creator>
      <dc:date>2023-02-23T16:42:09Z</dc:date>
    </item>
  </channel>
</rss>

