|
"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
|