[Scilab-users] Help with reading data (csvRead)
Claus Futtrup
cfuttrup at gmail.com
Sat Dec 10 15:52:57 CET 2016
Hi Rafael
So I gather that the separator has to be a single character, when using
csvRead.
Thanks for the tip, I'll use mfscanf instead, it seems to be tolerant ...
/Claus
On 10-12-2016 15:31, Rafael Guerra wrote:
>
> Hi Claus,
>
> I do not know how to handle multiple spaces separators in csvRead, but
> you can use following code (adapted from recent post by Serge Steer):
>
> // START OF CODE:
>
> u=mopen("example.zma","r");
>
> mgetl(u,5);// reads 5-line header
>
> r=mfscanf(-1,u,"%f %f %f\n");
>
> mclose(u)
>
> // END OF CODE
>
> Regards,
>
> Rafael
>
> *From:*users [mailto:users-bounces at lists.scilab.org] *On Behalf Of
> *Claus Futtrup
> *Sent:* Saturday, December 10, 2016 11:23 AM
> *To:* International users mailing list for Scilab.
> <users at lists.scilab.org>
> *Subject:* [Scilab-users] Help with reading data (csvRead)
>
> Hi
>
> I'm trying to read a datafile with csvRead, it might be the wrong
> function. Please help. The file itself looks like this (only showing
> select lines - the file contains 391 lines):
>
> ****************************************************
> * FILE:C:\Users\claus\example.zma <FILE:///C:/Users/claus/example.zma>
> * INFO: Arb1
> * Data: Impedance (ohms), Phase (degrees)
> ****************************************************
> 10.000 +8.8488 +40.1693
> 10.199 +8.9648 +40.7994
> 11.949 +10.0946 +46.1555
> 12.188 +10.2827 +46.7923
> 141.879 +6.7485 -10.8804
> 144.715 +6.7473 -10.3382
> 147.608 +6.7438 -9.8380
> 150.559 +6.7377 -9.3570
> 389.346 +7.2282 +9.7230
> 397.129 +7.2456 +10.0717
> 987.112 +8.5967 +23.3368
> 1006.846 +8.6355 +23.7056
> 9807.309 +26.8760 +57.2720
> 10003.368 +27.2519 +57.4330
> 20000.000 +44.3153 +62.1741
>
> csvRead complains because the column width is changing. I execute:
>
> localdir = "C:\Users\claus\";
> filename = _fullfile_(localdir,"example.zma");
> Mread = csvRead(filename," ",".","double",[],[],[],5);
>
> This is the error which csvRead gives (line 10 == line 3 in above
> shortened dataset):
>
> >Warning: Inconsistency found in the columns. At line 10, found 12 columns while the previous had 13.
> > !--error 999
> >csvRead: can not read file C:\Users\claus\example.zma: Error in the
> column structure
>
> What is the recommended way to read the ZMA file?
>
> P.S. ZMA = Impedance with 1) Frequency, 2) Magnitude and 3) Phase data.
>
> /Claus
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20161210/ca8a8fee/attachment.htm>
More information about the users
mailing list