<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172320</link>
    <title>MATLAB Central Newsreader - Extract just the header from a file</title>
    <description>Feed for thread: Extract just the header from a file</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 09 Jul 2008 23:02:04 -0400</pubDate>
      <title>Extract just the header from a file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172320#442161</link>
      <author>Amir </author>
      <description>Hi. I have files that are composed of several dozen lines &lt;br&gt;
of text (the header) followed by several thousand lines of &lt;br&gt;
numbers (the data); all the files are formatted like this. &lt;br&gt;
&lt;br&gt;
I'd like to extract in just the header. Right now I'm &lt;br&gt;
reading in the entire file with 'importdata' (and then &lt;br&gt;
extracting what I want), but that takes a very long time &lt;br&gt;
given how much numerical data there are. Is there a more &lt;br&gt;
elegant solution?&lt;br&gt;
&lt;br&gt;
Thanks!</description>
    </item>
    <item>
      <pubDate>Wed, 09 Jul 2008 23:57:34 -0400</pubDate>
      <title>Re: Extract just the header from a file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172320#442166</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;g53g1b$8dq$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
Amir  &amp;lt;amirschricker.DELETE@DELETE.gmail.DELETE.com&amp;gt; wrote:&lt;br&gt;
&amp;gt;Hi. I have files that are composed of several dozen lines &lt;br&gt;
&amp;gt;of text (the header) followed by several thousand lines of &lt;br&gt;
&amp;gt;numbers (the data); all the files are formatted like this. &lt;br&gt;
&lt;br&gt;
&amp;gt;I'd like to extract in just the header.&lt;br&gt;
&lt;br&gt;
Is the number of header lines constant? Or is it easily predictable&lt;br&gt;
from information that appears on the first line or two?&lt;br&gt;
&lt;br&gt;
Do all the header lines happen to start with the same sequence&lt;br&gt;
of characters (e.g., a '#' symbol at the beginning of each)?&lt;br&gt;
&lt;br&gt;
Is there a specific marker for the end of the headers?&lt;br&gt;
&lt;br&gt;
Is there something about the numberic lines that would allow you&lt;br&gt;
to figure, 100% certain, that you were into the numbers as&lt;br&gt;
soon as you had examined one of them?&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;&quot;Beauty, like all other qualities presented to human experience,&lt;br&gt;
&amp;nbsp;&amp;nbsp;is relative; and the definition of it becomes unmeaning and&lt;br&gt;
&amp;nbsp;&amp;nbsp;useless in proportion to its abstractness.&quot; -- Walter Pater</description>
    </item>
    <item>
      <pubDate>Thu, 10 Jul 2008 07:20:09 -0400</pubDate>
      <title>Re: Extract just the header from a file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172320#442189</link>
      <author>Andres </author>
      <description>&quot;Amir &quot; &amp;lt;amirschricker.DELETE@DELETE.gmail.DELETE.com&amp;gt; &lt;br&gt;
wrote in message &amp;lt;g53g1b$8dq$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi. I have files that are composed of several dozen lines &lt;br&gt;
&amp;gt; of text (the header) followed by several thousand lines &lt;br&gt;
of &lt;br&gt;
&amp;gt; numbers (the data); all the files are formatted like &lt;br&gt;
this. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'd like to extract in just the header. Right now I'm &lt;br&gt;
&amp;gt; reading in the entire file with 'importdata' (and then &lt;br&gt;
&amp;gt; extracting what I want), but that takes a very long time &lt;br&gt;
&amp;gt; given how much numerical data there are. Is there a more &lt;br&gt;
&amp;gt; elegant solution?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks!&lt;br&gt;
&lt;br&gt;
Maybe the automatic header line detection in txt2mat (file &lt;br&gt;
exchange) is of use to you if it is difficult to apply one &lt;br&gt;
of the methods Walter indicated. With&lt;br&gt;
&lt;br&gt;
[A,ffn,nh,SR,hl] = txt2mat(filename,'RowRange',[1 1]);&lt;br&gt;
&lt;br&gt;
you would read in one dummy data row of the file in &quot;A&quot; and &lt;br&gt;
the header lines as a single string in &quot;hl&quot; without having &lt;br&gt;
to read the whole file. &lt;br&gt;
Besides, to use importdata is definitely one of the slower &lt;br&gt;
ways to read in a file. If you find a self-made solution &lt;br&gt;
according to Walter's hints, it should rather base on &lt;br&gt;
textscan.&lt;br&gt;
&lt;br&gt;
Hth&lt;br&gt;
Andres</description>
    </item>
    <item>
      <pubDate>Thu, 10 Jul 2008 07:35:20 -0400</pubDate>
      <title>Re: Extract just the header from a file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172320#442191</link>
      <author>Rune Allnor</author>
      <description>On 10 Jul, 01:02, &quot;Amir &quot;&lt;br&gt;
&amp;lt;amirschricker.DEL...@DELETE.gmail.DELETE.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hi. I have files that are composed of several dozen lines&lt;br&gt;
&amp;gt; of text (the header) followed by several thousand lines of&lt;br&gt;
&amp;gt; numbers (the data); all the files are formatted like this.&lt;br&gt;
&lt;br&gt;
If this is a well-defined format, the header format will either&lt;br&gt;
be known in advance (i.e. how many lines in the header), or the&lt;br&gt;
size of a dynamic header will be sepcified in a known position&lt;br&gt;
in the file.&lt;br&gt;
&lt;br&gt;
You need to find out which it is, and then if necessary parse&lt;br&gt;
the header for the size. Once you know how the size of the&lt;br&gt;
header, use FGETL to read the lines.&lt;br&gt;
&lt;br&gt;
Rune</description>
    </item>
    <item>
      <pubDate>Thu, 10 Jul 2008 15:31:06 -0400</pubDate>
      <title>Re: Extract just the header from a file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172320#442279</link>
      <author>Carlos Adrian Vargas Aguilera</author>
      <description>Is better with TEXTEREAD function instead of FGETL. An you&lt;br&gt;
can specify how many lines to be readed.&lt;br&gt;
&lt;br&gt;
You could check out my READLINE function at File Exchange.&lt;br&gt;
&lt;br&gt;
Carlos Vargas</description>
    </item>
  </channel>
</rss>

