[scilab-Users] text file I/O

Mathieu Dubois mathieu.dubois at limsi.fr
Thu Jul 8 14:29:27 CEST 2010


Hello David,

I'm not an expert but I had to read those kind of files...
> fscanfMat fails while reading first non real element (date typically).
fscanfMat reads data written by fprintfMat... The hard part in your data 
is that it mixes text and numbers.
> Using formatted input fonctions like mfscanf or mgetl and msscanf 
> combination could be automated to adapt to different number of 
> numerical series : has anyone already written something like,that can 
> be shared ?
In your case you can:
1) read the number of data per line (on the first line)
2) create a format string using the right number of '%e'
3) use mfscanf with -1 iterations

The hard part is that you don't how many matrices mfscanf will return so 
you have to use the form L=mfscanf(-1, fd, format) and then reextract 
your data as a matrix.

Have a look at the attached files. I have tested it with the data you 
sent and a data set with 7 columns. It works.

HTH,
Mathieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20100708/eec0c386/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_mfscanf.tar.gz
Type: application/x-gzip
Size: 746 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20100708/eec0c386/attachment.bin>


More information about the users mailing list