[scilab-Users] Parsing ascii delimited data

Osvaldo Sergio Farhat de Carvalho osvaldo at dcc.ufmg.br
Wed Nov 4 10:12:02 CET 2009


Louis,

I suggest to use functions mgetl and tokens, as in

fd = mopen("data.csv","r");
while ~meof(fd)
  line = mgetl(fd,1) // get one line as a string
  T = tokens(line,";"); //T will be a string vector
  // do something with T
end
mclose(fd)

Osvaldo




                                                                                                                                                     
  De:         "Louis" <louis at awake24.de>                                                                                                             
                                                                                                                                                     
  Para:       <users at lists.scilab.org>                                                                                                               
                                                                                                                                                     
  Data:       03/11/2009 20:23                                                                                                                       
                                                                                                                                                     
  Assunto:    [scilab-Users] Parsing ascii delimited data                                                                                            
                                                                                                                                                     





Hi everyone.
I try to parse a ascii delimited file.
If I try to use fscanf I get this:

-->a=fscanf(‘data.csv', '%s;%s');
 !--error 999
msprintf: Wrong number of input arguments: data doesn't fit with format.
at line      51 of function sscanf called by :
[v1] = sscanf(buf,frmt);
in  execstr instruction    called by :
line    41 of function fscanf called by :
a=fscanf('kapitalkurven_quelle.csv', '%s;%s');





If I try to use mfscanf like this:
[n,a,b]=mfscanf(-1, u, '%s;%s');
It does not split the input line at ;.
So if I type a I get this:
!31.01.2003;115.918,60  !
!                       !
!€                      !!                       !
!aaaaa;1.1,10  !
!                       !
!€                      !!                       !
!bbbbbbb;1.2,50  !
!                       !
!€                      !!                       !
!cccccc;1.22,00  !
!                       !
!€                      !!                       !
!dddddd;1.3,20  !

Can someone help me so I will get something like this:
!aaaaaaa  ! 1.1,10 !

Thanks Louis.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20091104/566fbd46/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20091104/566fbd46/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20091104/566fbd46/attachment-0001.gif>


More information about the users mailing list