help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Textread from io package


From: PetrSt
Subject: Re: Textread from io package
Date: Wed, 10 Apr 2013 06:58:16 -0700 (PDT)

It's good to hear it helps. About the number of outputs, it was my fault that
I missed spaces (I'm using commas ...) , but it doesn't change anything.
Concerning transformation to desired output, here is something, which should
be more handy:

str = fileread ([pwd,'\others\test.log']);
[s, e, te, m, t, nm] = regexp (str','(\n(?
\d*)\t(?*\w*)\t(?<c>\w*)\t(?<d>\d*)\t)');
nl = size(t,2);
for ii=1:nl
        [a(ii,1),b(ii,1),c(ii,1),d(ii,1)] =
strread(t{ii}{1},'%d%s%s%d','delimiter','\t');
end

It' s not a big difference (I'm also new to regexp, so I'm trying what it
does). \d and \w works the same way as \S, so it doesn't matter which way
you use. I just hoped it makes the conversion from string to number,
avoiding the for loop, but it doesn't. The new approach is in using ?<name>,
what produces structure nm with fields a, b ,c and d containing cells of
particular columns (still strings, but maybe you can utilize it somehow).
Using of strread just looks better to me and there could be m insted of
t{ii}{1}, but it all depends on your demands.
Regards



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Textread-from-io-package-tp4651648p4651694.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]