[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: texscan(filename,'%s %s %s %n %s', 'delimiter', '; ') ## equivalent
From: |
Ben Abbott |
Subject: |
Re: texscan(filename,'%s %s %s %n %s', 'delimiter', '; ') ## equivalent in Octave ?? |
Date: |
Wed, 09 Jul 2008 08:30:11 -0700 |
On Wednesday, July 09, 2008, at 08:34AM, "Ambre Lili" <address@hidden> wrote:
>Hello everyone,
>
>I would like to find a precise Octave equivalent for the Matlab function
>'texscan'.
>
>More precisely, I have a text file containing rows like this one :
>19:45:21.3366; 00:25:56:84:b2:55; 00:e6:4b:bd:ac; 15887; 0x0028e36
>
>and the Matlab script is :
>
>tcpd_fid{i}=fopen(tcpd_log_file{i});
>tcpd_data{i}=textscan(tcpd_fid{i},'%s %s %s %n %s', 'delimiter', ';');
>fclose(tcpd_log_file{i});
>
>
>and I would like to obtain the same result(eg a cell array of five cells,
>each cell being a column vector) in Octave.
>
>Do anyone have an idea ?
>
>I´ve tried fscanf, fgetl and others but I am not successful in obtaining the
>same results
Perhaps you can use regexp as a work around?
octave:81> str = "19:45:21.3366; 00:25:56:84:b2:55; 00:e6:4b:bd:ac; 15887;
0x0028e36";
octave:82> pat = "[^;|^\\s]*[^;|^\\s]";
octave:83> regexp(str,"[^;|^\\s]*[^;|^\\s]","match")
ans =
{
[1,1] = 19:45:21.3366
[1,2] = 00:25:56:84:b2:55
[1,3] = 00:e6:4b:bd:ac
[1,4] = 15887
[1,5] = 0x0028e36
}
The result is all character data, so you'll still have to convert the 4th field
using str2num.
Ben