help-octave
[Top][All Lists]
Advanced

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

Re: problem reading file with time-stamps


From: BVBA NuKey Music
Subject: Re: problem reading file with time-stamps
Date: Tue, 13 Dec 2011 13:39:15 +0100

Thanks for replying but if I try out your code I get the following errors:
octave:3> A=textread("timestamps.txt", "%d", "delimiter", " ")
error: `textread' undefined near line 3 column 3
error: evaluating assignment _expression_ near line 3, column 2

and

octave:3> B=textread("timestamps.txt", "%s", "delimiter", " ");
error: `textread' undefined near line 3 column 3
error: evaluating assignment _expression_ near line 3, column 2

Any idea what is going wrong?

thanks in advance
nukey

2011/12/13 Joanna Cheng <address@hidden>
On Tue, Dec 13, 2011 at 7:51 PM, BVBA NuKey Music <address@hidden> wrote:
> I'm trying to read a file with four columns which has timestamps in the
> first column:
>
> The data is available in the file in the following format:
> Dec-13-09:46:45 21.4 +4.76442190E-01 8.135530E-06 1.553691E+00
> Dec-13-09:47:12 21.4 +4.76439120E-01 8.135839E-06 1.553726E+00
> Dec-13-09:47:39 21.4 +4.76427260E-01 8.136261E-06 1.553853E+00
>
> first field is a timestamp then a space followed by a temperature then a
> space ...
>
> As you can see here below, octave doesn't accept the file because of the
> timestamps,
> can anyone here help me solve this problem?
>
> octave:1> y=load('x7r0.7vac0vdc.dat');
> error: load: failed to read matrix from file `x7r0.7vac0vdc.dat'
> error: evaluating assignment _expression_ near line 1, column 2


I actually wrote a bit of code to do this with csv files. See here:
http://www.octave.org/wiki/index.php?title=Tips_and_tricks#Load_Comma_Separated_Values_.28.2A.csv.29_files

Sample output as below:

octave:19> A=textread("timestamps.txt", "%d", "delimiter", " ");
octave:20> B=textread("timestamps.txt", "%s", "delimiter", " ");
octave:21> inds = isnan(A);
octave:22> B(!inds) = num2cell(A(!inds));
octave:23> B
B =
{
 [1,1] = Dec-13-09:46:45
 [2,1] =  21.400
 [3,1] =  0.47644
 [4,1] = 8.1355e-006
 [5,1] =  1.5537
 [6,1] = Dec-13-09:47:12
 [7,1] =  21.400
 [8,1] =  0.47644
 [9,1] = 8.1358e-006
 [10,1] =  1.5537
 [11,1] = Dec-13-09:47:39
 [12,1] =  21.400
 [13,1] =  0.47643
 [14,1] = 8.1363e-006
 [15,1] =  1.5539
}
octave:24> class(B)
ans = cell
octave:25> class(B{1})
ans = char
octave:26> class(B{2})
ans = double

Hope that helps,
Joanna


reply via email to

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