Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: import uneven data file
Date: Fri, 23 May 2008 20:28:02 +0000 (UTC)
Organization: Pierburg GmbH
Lines: 37
Message-ID: <g179ci$cib$1@fred.mathworks.com>
References: <g16gp1$f5l$1@fred.mathworks.com> <21277086.1211562307457.JavaMail.jakarta@nitrogen.mathforum.org>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1211574482 12875 172.30.248.35 (23 May 2008 20:28:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 23 May 2008 20:28:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 872224
Xref: news.mathworks.com comp.soft-sys.matlab:470103



AMK <kennaster@gmail.com> wrote in message
<21277086.1211562307457.JavaMail.jakarta@nitrogen.mathforum.org>...
> And just to be clear, the 115 labeled rows have fewer
columns than the 101 rows.
> 
> AMK

So there are two distinct types of rows that you can tell by
there first element? I.e. a rare one beginning with 115
('type A') and the other with 101 ('type B')?! And you know
the number of elements of each row type, or at least that
the type B rows always have N=4 more elements then the type
A ones?!
Then there is a fast way with txt2mat from the file exchange
(sorry I'm biased to it, but I'm the author)


FileOrPath = 'c:\mydata'; 

A = txt2mat(FileOrPath,'ReplaceExpr',...
   {{'115',[repmat('NaN,',1,4) '115']}});

q = isnan(A(:,1)) ;

x1 = A(find(q),5:end);
x2 = A(find(~q),:);


txt2mat can 'natively' handle files with different row
lengths as well (see it's help), but I suppose using the
replacement trick above will speed things up. Feel free to
contact me (via the fex form) if you think the import takes
too long, or if any problems occur.
There are certainly many other solutions.
Best wishes
Andres