[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 05:18:26 -0700 (PDT) |
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.
2) Textread doesn't return single argument. Equal number of outputs to
format specifier must be given instead.
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.
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
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.