AW: [scilab-Users] Parsing ascii delimited data

Louis louis at awake24.de
Wed Nov 4 18:02:06 CET 2009


Is there no other way with fewer code?

I thought about reading into a struct directly, because it looks

Like, a matrix or array can only hold values of a single type.

Do the other functions not work properly and need to be fixed?

 

Thanks for your answer Louis.

 

 

Von: Osvaldo Sergio Farhat de Carvalho [mailto:osvaldo at dcc.ufmg.br] 
Gesendet: Mittwoch, 4. November 2009 10:12
An: users at lists.scilab.org
Betreff: Re: [scilab-Users] Parsing ascii delimited data

 

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



Ocultação de detalhes inativa de"Louis" ---03/11/2009 20:23:10---Hi everyone."Louis" ---03/11/2009 20:23:10---Hi everyone.



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/0e209b09/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20091104/0e209b09/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 168 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20091104/0e209b09/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 166 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20091104/0e209b09/attachment-0001.png>


More information about the users mailing list