<?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 exclude header and footer when using open () to import a text file, in JSL? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-exclude-header-and-footer-when-using-open-to-import-a/m-p/443898#M69185</link>
    <description>&lt;P&gt;One way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;filename = Save Text File(
	"$temp/deleteme.txt",
	"\[! header first line
! header second line
Parameter         LSL   USL     Units
voltage              0.1    0.5        V
Capacitance     0.3    0.7       pF
Resistance        0.5     9       Ohms
! Footer second line
! Footer third line
! Footer third line]\"
);

lines = Words( Load Text File( filename ), "\!n\!r" );

metadata = {};
data = {};
For( i = 1, i &amp;lt;= N Items( lines ), i += 1,
	line = lines[i];
	If( Starts With( line, "!" ),
		Insert Into( metadata, line ),
		Insert Into( data, line )
	);
);

datafilename = Save Text File( "$temp\data.txt", Concat Items( data, "\!n" ) );
metafilename = Save Text File( "$temp\metadata.txt", Concat Items( metadata, "\!n" ) );
dtData = Open( datafilename, Import Settings( End Of Field( Tab, Spaces, Space ) ) );
dtMetadata = Open( metafilename, Import Settings( Labels( 0 ) ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="meta data separated from data" style="width: 592px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38281iC76849C1D69083E8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="meta data separated from data" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;meta data separated from data&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Dec 2021 23:06:36 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2021-12-09T23:06:36Z</dc:date>
    <item>
      <title>How to exclude header and footer when using open () to import a text file, in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-exclude-header-and-footer-when-using-open-to-import-a/m-p/443851#M69184</link>
      <description>&lt;P&gt;I have data which has several header rows at the beginning of data and footer at the end of the data.&lt;/P&gt;&lt;P&gt;Both header and footer text start with an identifier &lt;EM&gt;!&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;(number of rows of header, footer and data in-between vary)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example with arbitrary data (available as .txt file)&lt;/P&gt;&lt;P&gt;! header first line&lt;/P&gt;&lt;P&gt;! header second line&lt;/P&gt;&lt;P&gt;Parameter&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LSL&amp;nbsp; &amp;nbsp;USL&amp;nbsp; &amp;nbsp; &amp;nbsp;Units&lt;/P&gt;&lt;P&gt;voltage&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.1&amp;nbsp; &amp;nbsp; 0.5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; V&lt;/P&gt;&lt;P&gt;Capacitance&amp;nbsp; &amp;nbsp; &amp;nbsp;0.3&amp;nbsp; &amp;nbsp; 0.7&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pF&lt;/P&gt;&lt;P&gt;Resistance&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.5&amp;nbsp; &amp;nbsp; &amp;nbsp;9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Ohms&lt;/P&gt;&lt;P&gt;! Footer second line&lt;/P&gt;&lt;P&gt;! Footer third line&lt;/P&gt;&lt;P&gt;! Footer third line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I use open () so that I can exclude header and footer data while importing data in text format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to use open() to import data keeping the header and footer text (say into a table &lt;EM&gt;dt&lt;/EM&gt;).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also want to know how to extract (to a new table &lt;EM&gt;dt_new&lt;/EM&gt;) data excluding the header and footer which start with an identifier, say &lt;EM&gt;!.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally, I want to save the header and footer data in &lt;EM&gt;dt&lt;/EM&gt;&amp;nbsp;in a separate table, say &lt;EM&gt;dt_hf. &lt;/EM&gt;How to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:41:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-exclude-header-and-footer-when-using-open-to-import-a/m-p/443851#M69184</guid>
      <dc:creator>Neo</dc:creator>
      <dc:date>2023-06-10T23:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude header and footer when using open () to import a text file, in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-exclude-header-and-footer-when-using-open-to-import-a/m-p/443898#M69185</link>
      <description>&lt;P&gt;One way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;filename = Save Text File(
	"$temp/deleteme.txt",
	"\[! header first line
! header second line
Parameter         LSL   USL     Units
voltage              0.1    0.5        V
Capacitance     0.3    0.7       pF
Resistance        0.5     9       Ohms
! Footer second line
! Footer third line
! Footer third line]\"
);

lines = Words( Load Text File( filename ), "\!n\!r" );

metadata = {};
data = {};
For( i = 1, i &amp;lt;= N Items( lines ), i += 1,
	line = lines[i];
	If( Starts With( line, "!" ),
		Insert Into( metadata, line ),
		Insert Into( data, line )
	);
);

datafilename = Save Text File( "$temp\data.txt", Concat Items( data, "\!n" ) );
metafilename = Save Text File( "$temp\metadata.txt", Concat Items( metadata, "\!n" ) );
dtData = Open( datafilename, Import Settings( End Of Field( Tab, Spaces, Space ) ) );
dtMetadata = Open( metafilename, Import Settings( Labels( 0 ) ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="meta data separated from data" style="width: 592px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38281iC76849C1D69083E8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="meta data separated from data" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;meta data separated from data&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 23:06:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-exclude-header-and-footer-when-using-open-to-import-a/m-p/443898#M69185</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2021-12-09T23:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude header and footer when using open () to import a text file, in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-exclude-header-and-footer-when-using-open-to-import-a/m-p/444489#M69248</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/982"&gt;@Craige_Hales&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What changes are needed if my data is in a data table and not in a text file?&lt;/P&gt;&lt;P&gt;(I load the text file and call it say &lt;EM&gt;dt&lt;/EM&gt;).&lt;/P&gt;&lt;P&gt;Now I need to separate the header and footer from &lt;EM&gt;dt.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, how to handle empty lines between header and footer entries, e.g. empty space between &lt;EM&gt;footer second line&lt;/EM&gt; and &lt;EM&gt;footer third line&lt;/EM&gt; and not include them in &lt;EM&gt;data&lt;/EM&gt;?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 14:33:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-exclude-header-and-footer-when-using-open-to-import-a/m-p/444489#M69248</guid>
      <dc:creator>Neo</dc:creator>
      <dc:date>2021-12-13T14:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude header and footer when using open () to import a text file, in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-exclude-header-and-footer-when-using-open-to-import-a/m-p/444591#M69255</link>
      <description>&lt;P&gt;Is this what your data table looks like?&amp;nbsp; If not, can you supply a sample data table?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1639409314586.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38373i858A59A6FF76CCE0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1639409314586.png" alt="txnelson_0-1639409314586.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 15:28:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-exclude-header-and-footer-when-using-open-to-import-a/m-p/444591#M69255</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-12-13T15:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude header and footer when using open () to import a text file, in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-exclude-header-and-footer-when-using-open-to-import-a/m-p/444636#M69258</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;. Below is how it looks like. I would like to do the following&lt;/P&gt;&lt;P&gt;1. Separate the header and footer text into one list.&lt;/P&gt;&lt;P&gt;2. Separate the data between the header and foot except the empty line into a data table.&lt;/P&gt;&lt;P&gt;3. Count the number of empty entries in the data table (they change depending on which text file is loaded)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtbl.PNG" style="width: 591px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38376i6F26DBDFFD68DF3C/image-size/large?v=v2&amp;amp;px=999" role="button" title="dtbl.PNG" alt="dtbl.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 16:46:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-exclude-header-and-footer-when-using-open-to-import-a/m-p/444636#M69258</guid>
      <dc:creator>Neo</dc:creator>
      <dc:date>2021-12-13T16:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude header and footer when using open () to import a text file, in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-exclude-header-and-footer-when-using-open-to-import-a/m-p/444776#M69273</link>
      <description>&lt;P&gt;Here is a simple example of what I think you need.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

headFootList = {};
col1Name = Column( 1 ) &amp;lt;&amp;lt; get name;
Eval(
	Parse(
		Eval Insert(
			"For Each Row( If( Contains( :^col1Name^, \!"!\!" ) == 1, Insert Into( headFootList, :^col1Name^ ) ) )"
		)
	)
);

Eval(
	Parse(
		Eval Insert(
			"emptyCount = N Rows( dt &amp;lt;&amp;lt; get rows where( :^col1Name^ == \!"\!" ) )"
		)
	)
);
Eval(
	Parse(
		Eval Insert(
			"dt &amp;lt;&amp;lt; select where( contains(:^col1Name^,\!"!\!")==1 | :^col1Name^ == \!"\!")"
		)
	)
);
Try( dt &amp;lt;&amp;lt; delete rows );

dtHeadFoot = New Table( "Headers and Footers",
	New Column( "Headers and Footers", character, set values( headFootList ) )
);

New Window( "Count of Empty Rows",
	&amp;lt;&amp;lt;modal,
	Spacer Box( size( 0, 15 ) ),
	H List Box( Text Box( "The numer of empty rows is: " || Char( emptyCount ) ) )
);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Dec 2021 05:06:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-exclude-header-and-footer-when-using-open-to-import-a/m-p/444776#M69273</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-12-14T05:06:45Z</dc:date>
    </item>
  </channel>
</rss>

