help-octave
[Top][All Lists]
Advanced

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

Re: Textread from io package


From: Daniel Arteaga
Subject: Re: Textread from io package
Date: Wed, 10 Apr 2013 15:24:09 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5

Dear PetrSt,

Al 10/04/13 14:18, En/na PetrSt ha escrit:
Daniel Arteaga-2 wrote
[Trial Event_Type Code
Time]=textread('test.log','%d%s%s%d%*[^\n]','headerlines',5);

In Octave 3.6.2 raises an error (both tested in Ubuntu 12.10 and Windows)

1) What type of error? First error I got was related to absence of number of
repeating. Despite the manual to textread it seems that this input argument
is not optional, so textread(file,format,[],options), or similar, must be
specified.

I noticed this first error. That there is a bug whenever you only specify 'headerlines' and not any other option.

2) Textread doesn't return single argument. Equal number of outputs to
format specifier must be given instead.

I think that was a problem of automatic line wrapping in the email client. I meant:

Trial Event_Type Code  Time]= ...
textread('test.log','%d%s%s%d%*[^\n]','headerlines',5);

3) It doesn't work anyway. I tried also textscan with similar result, i.e. I
got the output but the parsing was incorrect. Even adding 0\t to several
first lines to got the same formating for those lines didn't help.

Same happened to me

4) This code worked just fine:

str = fileread ('test.log');
[s, e, te, m, t, nm] = regexp (str','(\n(\S*)\t(\S*)\t(\S*)\t(\S*)\t)');
nl = size(t,2);
for ii=1:nl
        a(ii,1) = str2num(t{ii}{2});
        b{ii,1} = t{ii}{3};
        c{ii,1} = t{ii}{4};
        d(ii,1) = str2num(t{ii}{5});
end

Thank you very much! That piece of code worked fine for me.

Best,

Daniel


Maybe the transformation of cell t to desired outputs could be done more
effectively.



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




reply via email to

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