[scilab-Users] can not read all words in a ascii file
Mathieu Dubois
mathieu.dubois at limsi.fr
Wed Feb 9 11:18:17 CET 2011
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/a7ad3475/attachment.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: P_70
URL: <https://lists.scilab.org/pipermail/users/attachments/20110209/a7ad3475/attachment.ksh>
More information about the users
mailing list