[Scilab-users] Help with text files

Eduardo Torrecillas eduardo.torrecillas at gmail.com
Wed Nov 27 16:40:06 CET 2013


Hello Antoine!

Looks like the problem is solved, and actually has nothing to do with
SciLab, but with file encoding!

Thank you very much!

Best regards,


On Wed, Nov 27, 2013 at 6:07 AM, Antoine Monmayrant <
antoine.monmayrant at laas.fr> wrote:

>  On 11/26/2013 07:13 PM, Eduardo Torrecillas wrote:
>
>     Hello all,
>
>  I currently have some text files and I would like to extract information
> from them using Scilab.
> I have done this before, using mopen and mgetl, for example.
>
>  Don't know why, but strangely in this case it is not working. I am using
> Scilab 5.4.1 on Ubuntu (but Scilab 5.4.0 under Windows produced the same
> result).
>
>  Please check the attached text file.
>
>  Simple code such as:
>
> fd=mopen('scilab_example.txt','r')
>  phrase=mgetl(fd,1)
>
>  Produces:
>
>  phrase=ÿp
>
>  If i still try to use mgetl, next lines are always returned as empty.
>
> Does anybody have any clue on whats happening?
>
> Best regards,
>
> --
> Eduardo Torrecillas
> AER-09
>
>
> _______________________________________________
> users mailing listusers at lists.scilab.orghttp://lists.scilab.org/mailman/listinfo/users
>
>
> Hi,
>
> Here is what I found:
>
> On my linux box, it seems your file is UTF-16:
>
> $ file scilab_example.txt
> scilab_example.txt: Little-endian UTF-16 Unicode text, with CRLF, CR line
> terminators
>
> I cannot read it with mgetl, but I can use mgetstr:
>
> -->fd=mopen('scilab_example.txt','r')
>  fd  =
>
>     1.
>
> -->chars=mgetstr(50)
>  chars  =
>
>  ��                          6 0 A     4 8 8 F / 1
>
> -->chars=mgetstr(50)
>  chars  =
>
>  9 - 1 9 - 2 1   4 8 8 * / 1 9 - 1 9 - 2 1     4 8
>
> -->chars=mgetstr(50)
>  chars  =
>
>  8 * / 1 9 - 1 9 - 2 1     4 8 8 * / 1 9 - 1 9 - 2
>
>
> As you can see, it looks like a problem of encoding (the  �� or the ÿp are
> usually showing up when encoding is wrong).
> You can solve it that way:
>
> $ iconv -f UTF-16 -t LATIN1 scilab_example.txt > latin1.txt
>
> than in Scilab:
>
> -->fd=mopen('latin1.txt','r')
>  fd  =
>
>     1.
>
> -->phrase=mgetl(fd,1)
>  phrase  =
>
>               60A  488F/19-19-21 488*/19-19-21  488*/19-19-21
> 488*/19-19-21
>
> Hope it helps
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>


-- 
Eduardo Torrecillas
AER-09
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20131127/8f37cf8c/attachment.htm>


More information about the users mailing list