[scilab-Users] can not read all words in a ascii file

Loïc GIROD Loic.Girod at esstin.uhp-nancy.fr
Wed Feb 9 11:44:58 CET 2011


Hello Mathieu, 

 

Thanks for the help. Indeed, it does not work with my file but it works with
your example.

 

Bye

 

Loïc

 

 

--

 

De : Mathieu Dubois [mailto:mathieu.dubois at limsi.fr] 
Envoyé : mercredi 9 février 2011 11:18
À : users at lists.scilab.org
Objet : Re: [scilab-Users] can not read all words in a ascii file

 

Hello,

The fact that you get a string matrix is related to the way mscanf works
(it's a bit complicated, see the examples in help page). Basically, like
scanf in C, %s reads a string delimited by whitespace (therefore you get a
string per word).

To read lines in a file see mgetl.

I didn't succeed to read the file you send (it looks like it contains
strange bytes and maybe that's why mscanf don't works) but it works with the
attached file.
-->fd4 = mopen("P_70",'r');
 
-->mgetl(fd4)
 ans  =
 
 A legendary legend 

Mathieu

On 02/09/2011 10:19 AM, Loïc GIROD wrote: 

Hello !

 

I try to read the characters in the attached ASCII file.

I would like to use the strings to make a legend in a graph.

 

I use the following code : 

fd4 = mopen("P_70",'r')

x=mfscanf(-1,fd4,'%s')

 

but I get : 

x  =

 

!                !

!                 !

!des              !

!                 !

!points           !

!                 !

!de               !

!                 !

!transformations  !

!                 !

!simple           !

!                 !

!DSC              !

!                 !

!Essai            !

!                 !

!A                !

!                 !

!Air              !

!                 !

!Alu              !

!                 !

!                 !

!                 !

!A                !

!                 !

!A                !

!                 !

!A                !

!                 !

!A                !

!                 !

!A                !

!                 !

!D                !

!                 !

!D                !

 

 

As you can see, the first word is missing and I don’t understand why.

Then I have not found how to convert x in a single string.

 

Many thanks for the help

 

Best regards

 

Loïc

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20110209/2babf64c/attachment.htm>


More information about the users mailing list