Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Text file with numbers and text, want to just read numbers
Date: Fri, 4 Jul 2008 06:55:06 +0000 (UTC)
Organization: University of Memphis
Lines: 51
Message-ID: <g4khga$3qe$1@fred.mathworks.com>
References: <g4jc5p$341$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1215154506 3918 172.30.248.38 (4 Jul 2008 06:55:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 4 Jul 2008 06:55:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 233092
Xref: news.mathworks.com comp.soft-sys.matlab:477484



"Matt " <matthew.r.duncan@boeing.com> wrote in message
<g4jc5p$341$1@fred.mathworks.com>...
> I have a series of text files I want to read.  The files 
> begin with header information.  The number of rows of 
> header information changes, there is no commenting symbol 
> such as %%, and the header information sometimes has 
> numbers such as a date or a time.  I want to read in the 
> number and only the numbers.  
> 
> This is an example of a file: (Again, the header info 
> changes, different # of lines, different text)
> 
> Vector Signal [Measurement4]:  09/27/2006, 09:05:24
> Units: EU
> Time	 Real
>             0	      0.053732
>      9.6e-005	       0.11968
>      0.000192	      0.085483
>      0.000288	       0.11968
>      0.000384	       0.18562
> 
> Currently I have Matlab code something like this:
> 
> [filename, pathname, filterindex] = uigetfile
> ({'*.txt','Text file (*.txt)';'*.*','All Files 
> (*.*)'},'Pick Time History File');
> fid = fopen(filename);
> C_text = textscan(fid,'%s');
> fclose(fid);
> 
> 
> I tried to sort out the header from C_text by creating a 
> loop searching for numbers.  Example, seeing if the 
> absolute value is greater than one.  This method failed 
> when it ran into dates and times.  
> 
> Is there a better way?  I've been trying to use textscan, 
> but I have also been looking at fscan and textread.  I 
> think there may be some formatting with C_text that could 
> work, but I couldn't get it to work.  
> 
> 
> 
> 
> 

I would read the headers with fgetl and then decide if the
first character is a letter, which indicates a header line
in your example.  Once past the headers, I would then read
the data with a textscan.