Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Extract just the header from a file
Date: Thu, 10 Jul 2008 07:20:09 +0000 (UTC)
Organization: Pierburg GmbH
Lines: 33
Message-ID: <g54d79$l28$1@fred.mathworks.com>
References: <g53g1b$8dq$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1215674409 21576 172.30.248.37 (10 Jul 2008 07:20:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 10 Jul 2008 07:20:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 872224
Xref: news.mathworks.com comp.soft-sys.matlab:478543



"Amir " <amirschricker.DELETE@DELETE.gmail.DELETE.com> 
wrote in message <g53g1b$8dq$1@fred.mathworks.com>...
> Hi. I have files that are composed of several dozen lines 
> of text (the header) followed by several thousand lines 
of 
> numbers (the data); all the files are formatted like 
this. 
> 
> I'd like to extract in just the header. Right now I'm 
> reading in the entire file with 'importdata' (and then 
> extracting what I want), but that takes a very long time 
> given how much numerical data there are. Is there a more 
> elegant solution?
> 
> Thanks!

Maybe the automatic header line detection in txt2mat (file 
exchange) is of use to you if it is difficult to apply one 
of the methods Walter indicated. With

[A,ffn,nh,SR,hl] = txt2mat(filename,'RowRange',[1 1]);

you would read in one dummy data row of the file in "A" and 
the header lines as a single string in "hl" without having 
to read the whole file. 
Besides, to use importdata is definitely one of the slower 
ways to read in a file. If you find a self-made solution 
according to Walter's hints, it should rather base on 
textscan.

Hth
Andres