Re: [Scilab-users] using csvRead

2016-10-14 Thread Philipp Mühlmann
Dear Denis,

yes thats the way I do it right now.

use mopen --> open file for reading
use mgetl --> read data, result = array of strings
use strsplit --> split  string Array as desired

use evestring() --> convert string to double

Point of disadvantage

So fa I know strsplit() can handle only one string.
Hence I use a for-loop to split each line of the Initial string array into
a group of strings and convert each part into a double.

OK for few data...may take long for many data

Idea:

Read data from file and try to spare conversation string-to-double.

fscanfMat() won't do it, because the data does not contain only numerical
values and "."-sign as decimal.

So I tried csvRead.

using the help I find:  separator :  a 1-by-1 matrix of strings, the
field separator used.


Note:   STRINGS   = plural.

So I wonder if it is possible to have more than one separator here.




BR
Philipp

mclose( :-) )


2016-10-14 0:51 GMT+02:00 CRETE Denis :

> Hello Philipp,
>
>
>
> In this case I first attempt to read first (e.g. with “mopen” and “getl”)
> and then split the strings with “tokens” where the feature of multiple
> separators exists.
>
> Of course you can also use “cvsRead” with one separator and then use
> “tokens” to finish with the other separators.
>
> HTH
>
> Denis
>
>
>
> [@@ THALES GROUP INTERNAL @@]
>
>
>
> Unité Mixte de Physique CNRS / THALES
>
> 1 Avenue Augustin Fresnel
>
> 91767 Palaiseau CEDEx - France
>
> Tel : +33 (0)1 69 41 58 52 Fax : +33 (0)1 69 41 58 78
>
> e-mail :
>
>  denis.cr...@thalesgroup.com  <%20denis.cr...@thalesgroup.com>>
>
> http://www.trt.thalesgroup.com/ump-cnrs-thales
>
> http://www.research.thalesgroup.com
>
>
>
> *De :* users [mailto:users-boun...@lists.scilab.org] *De la part de*
> Philipp Mühlmann
> *Envoyé :* vendredi 14 octobre 2016 00:08
> *À :* International users mailing list for Scilab.
> *Objet :* [Scilab-users] using csvRead
>
>
>
> Dear Scilab users,
>
> having a data file (*.cvs) containg following format:
>
> HEADER-Line
>
> dd.mm., HH:MM:SS.MS, value01, value02
>
> dd = day
>
> mm = month
>
>  = year
>
> HH = hour
>
> MM = minute
>
> SS = second
>
> Ms = milli second
>
> ValueXY = numerical value
>
>
>
> Is it possible to use cvsRead in such a way to define the separator beeing
> ',' and ':' at the same time?
>
> Background:
>
> desired Matrix after reading the file is
>
> M = [dd mm  HH MM SS MS value1 value2]
>
>
>
> Thank you,
>
> Philipp
>
>
>
> --
>
> In Kanada is' ka' na' da. Sonst wär' Kanada Jemanda.
>
>
>
> There we have the salad.
>
> ___
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>


-- 
In Kanada is' ka' na' da. Sonst wär' Kanada Jemanda.

There we have the salad.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] using csvRead

2016-10-14 Thread Rafael Guerra
Hello Philipp,

Say that after mopen you got all your text input into array of strings ‘txt’:

txt = [
"HEADER-Line",
"01.12.2015, 01:15:00.12, 1.1, -2.2";
"03.12.2015, 11:15:00.12, -11.1, 2.5";
"12.12.2015, 21:15:00.12, 5.1, 6.2"];

Then do the following:

tx=txt(2:$);  // get rid of header line
tx1=part(tx,1:24);  // get date and time
tx2=part(tx,25:$);  // get numeric data values
// Now get rid of separators:
tx1 = strsubst(tx1,'.',' ');
tx1 = strsubst(tx1,':',' ');
tx1 = strsubst(tx1,',',' ');
tx2 = strsubst(tx2,',',' ');
tx = [tx1 tx2]; // regroups all data but now with numeric values only

Use  mputl to output ‘tx’ to temporary disk file and use fscanfMat to read like 
a breeze the large disk file (now fully numeric) into a Scilab numeric matrix 
‘M’.

Regards,
Rafael

From: users [mailto:users-boun...@lists.scilab.org] On Behalf Of Philipp 
Mühlmann
Sent: Friday, October 14, 2016 11:50 AM
To: Users mailing list for Scilab 
Subject: Re: [Scilab-users] using csvRead

Dear Denis,

yes thats the way I do it right now.

use mopen --> open file for reading
use mgetl --> read data, result = array of strings
use strsplit --> split  string Array as desired

use evestring() --> convert string to double

Point of disadvantage

So fa I know strsplit() can handle only one string.
Hence I use a for-loop to split each line of the Initial string array into a 
group of strings and convert each part into a double.

OK for few data...may take long for many data

Idea:
Read data from file and try to spare conversation string-to-double.
fscanfMat() won't do it, because the data does not contain only numerical 
values and "."-sign as decimal.
So I tried csvRead.
using the help I find:  separator :  a 1-by-1 matrix of strings, the field 
separator used.

Note:   STRINGS   = plural.

So I wonder if it is possible to have more than one separator here.

BR
Philipp

mclose( :-) )


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] using csvRead

2016-10-14 Thread Rafael Guerra
Correction:  after having obtained ‘tx’ as below, just do:M=evstr(tx);

From: users [mailto:users-boun...@lists.scilab.org] On Behalf Of Rafael Guerra
Sent: Friday, October 14, 2016 12:53 PM
To: Users mailing list for Scilab 
Subject: Re: [Scilab-users] using csvRead

Hello Philipp,

Say that after mopen you got all your text input into array of strings ‘txt’:

txt = [
"HEADER-Line",
"01.12.2015, 01:15:00.12, 1.1, -2.2";
"03.12.2015, 11:15:00.12, -11.1, 2.5";
"12.12.2015, 21:15:00.12, 5.1, 6.2"];

Then do the following:

tx=txt(2:$);  // get rid of header line
tx1=part(tx,1:24);  // get date and time
tx2=part(tx,25:$);  // get numeric data values
// Now get rid of separators:
tx1 = strsubst(tx1,'.',' ');
tx1 = strsubst(tx1,':',' ');
tx1 = strsubst(tx1,',',' ');
tx2 = strsubst(tx2,',',' ');
tx = [tx1 tx2]; // regroups all data but now with numeric values only

Use  mputl to output ‘tx’ to temporary disk file and use fscanfMat to read like 
a breeze the large disk file (now fully numeric) into a Scilab numeric matrix 
‘M’.

Regards,
Rafael

From: users [mailto:users-boun...@lists.scilab.org] On Behalf Of Philipp 
Mühlmann
Sent: Friday, October 14, 2016 11:50 AM
To: Users mailing list for Scilab 
mailto:users@lists.scilab.org>>
Subject: Re: [Scilab-users] using csvRead

Dear Denis,

yes thats the way I do it right now.

use mopen --> open file for reading
use mgetl --> read data, result = array of strings
use strsplit --> split  string Array as desired

use evestring() --> convert string to double

Point of disadvantage

So fa I know strsplit() can handle only one string.
Hence I use a for-loop to split each line of the Initial string array into a 
group of strings and convert each part into a double.

OK for few data...may take long for many data

Idea:
Read data from file and try to spare conversation string-to-double.
fscanfMat() won't do it, because the data does not contain only numerical 
values and "."-sign as decimal.
So I tried csvRead.
using the help I find:  separator :  a 1-by-1 matrix of strings, the field 
separator used.

Note:   STRINGS   = plural.

So I wonder if it is possible to have more than one separator here.

BR
Philipp

mclose( :-) )


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] using csvRead

2016-10-14 Thread Rafael Guerra
NOTE:  fyi, after testing over very large text files, it happens that doing 
mputl of  ‘tx’ to disk followed by M=fscanfMat is much faster than doing simply 
 M=evstr(tx) …


From: users [mailto:users-boun...@lists.scilab.org] On Behalf Of Rafael Guerra
Sent: Friday, October 14, 2016 12:58 PM
To: Users mailing list for Scilab 
Subject: Re: [Scilab-users] using csvRead

Correction:  after having obtained ‘tx’ as below, just do:M=evstr(tx);

From: users [mailto:users-boun...@lists.scilab.org] On Behalf Of Rafael Guerra
Sent: Friday, October 14, 2016 12:53 PM
To: Users mailing list for Scilab 
mailto:users@lists.scilab.org>>
Subject: Re: [Scilab-users] using csvRead

Hello Philipp,

Say that after mopen you got all your text input into array of strings ‘txt’:

txt = [
"HEADER-Line",
"01.12.2015, 01:15:00.12, 1.1, -2.2";
"03.12.2015, 11:15:00.12, -11.1, 2.5";
"12.12.2015, 21:15:00.12, 5.1, 6.2"];

Then do the following:

tx=txt(2:$);  // get rid of header line
tx1=part(tx,1:24);  // get date and time
tx2=part(tx,25:$);  // get numeric data values
// Now get rid of separators:
tx1 = strsubst(tx1,'.',' ');
tx1 = strsubst(tx1,':',' ');
tx1 = strsubst(tx1,',',' ');
tx2 = strsubst(tx2,',',' ');
tx = [tx1 tx2]; // regroups all data but now with numeric values only

Use  mputl to output ‘tx’ to temporary disk file and use fscanfMat to read like 
a breeze the large disk file (now fully numeric) into a Scilab numeric matrix 
‘M’.

Regards,
Rafael

From: users [mailto:users-boun...@lists.scilab.org] On Behalf Of Philipp 
Mühlmann
Sent: Friday, October 14, 2016 11:50 AM
To: Users mailing list for Scilab 
mailto:users@lists.scilab.org>>
Subject: Re: [Scilab-users] using csvRead

Dear Denis,

yes thats the way I do it right now.

use mopen --> open file for reading
use mgetl --> read data, result = array of strings
use strsplit --> split  string Array as desired

use evestring() --> convert string to double

Point of disadvantage

So fa I know strsplit() can handle only one string.
Hence I use a for-loop to split each line of the Initial string array into a 
group of strings and convert each part into a double.

OK for few data...may take long for many data

Idea:
Read data from file and try to spare conversation string-to-double.
fscanfMat() won't do it, because the data does not contain only numerical 
values and "."-sign as decimal.
So I tried csvRead.
using the help I find:  separator :  a 1-by-1 matrix of strings, the field 
separator used.

Note:   STRINGS   = plural.

So I wonder if it is possible to have more than one separator here.

BR
Philipp

mclose( :-) )


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] using csvRead

2016-10-14 Thread Philipp Mühlmann
Dear Rafael,

thank you for the example.

One comment:

before mputl(tx,fd)

I had to use:

tx = [tx1+tx2]--> 3 x 1 matrix

instead of

tx = [tx1 tx2]   --> 3 x 2 matrix, does not work with mputl

However,
thanks for the solution.
Philipp



2016-10-14 13:28 GMT+02:00 Rafael Guerra :

> NOTE:  fyi, after testing over very large text files, it happens that
> doing *mputl* of  ‘tx’ to disk followed by *M=fscanfMat *is much faster
> than doing simply*  M=evstr(tx) *…
>
>
>
>
>
> *From:* users [mailto:users-boun...@lists.scilab.org] *On Behalf Of *Rafael
> Guerra
> *Sent:* Friday, October 14, 2016 12:58 PM
>
> *To:* Users mailing list for Scilab 
> *Subject:* Re: [Scilab-users] using csvRead
>
>
>
> *Correction:*  after having obtained ‘tx’ as below, just do:M=evstr(tx
> );
>
>
>
> *From:* users [mailto:users-boun...@lists.scilab.org
> ] *On Behalf Of *Rafael Guerra
> *Sent:* Friday, October 14, 2016 12:53 PM
> *To:* Users mailing list for Scilab 
> *Subject:* Re: [Scilab-users] using csvRead
>
>
>
> Hello Philipp,
>
>
>
> Say that after *mopen* you got all your text input into array of strings
> ‘txt’:
>
>
>
> txt = [
>
> "HEADER-Line",
>
> "01.12.2015, 01:15:00.12, 1.1, -2.2";
>
> "03.12.2015, 11:15:00.12, -11.1, 2.5";
>
> "12.12.2015, 21:15:00.12, 5.1, 6.2"];
>
>
>
> Then do the following:
>
>
>
> tx=txt(2:$);  // get rid of header line
>
> tx1=part(tx,1:24);  // get date and time
>
> tx2=part(tx,25:$);  // get numeric data values
>
> // Now get rid of separators:
>
> tx1 = strsubst(tx1,'.',' ');
>
> tx1 = strsubst(tx1,':',' ');
>
> tx1 = strsubst(tx1,',',' ');
>
> tx2 = strsubst(tx2,',',' ');
>
> tx = [tx1 tx2]; // regroups all data but now with numeric values only
>
>
>
> Use  *mputl* to output ‘tx’ to temporary disk file and use *fscanfMat* to
> read like a breeze the large disk file (now fully numeric) into a Scilab
> numeric matrix ‘M’.
>
>
>
> Regards,
>
> Rafael
>
>
>
> *From:* users [mailto:users-boun...@lists.scilab.org
> ] *On Behalf Of *Philipp Mühlmann
> *Sent:* Friday, October 14, 2016 11:50 AM
> *To:* Users mailing list for Scilab 
> *Subject:* Re: [Scilab-users] using csvRead
>
>
>
> Dear Denis,
>
>
>
> yes thats the way I do it right now.
>
>
>
> use mopen --> open file for reading
>
> use mgetl --> read data, result = array of strings
>
> use strsplit --> split  string Array as desired
>
>
>
> use evestring() --> convert string to double
>
>
>
> Point of disadvantage
>
>
>
> So fa I know strsplit() can handle only one string.
>
> Hence I use a for-loop to split each line of the Initial string array into
> a group of strings and convert each part into a double.
>
>
>
> OK for few data...may take long for many data
>
>
>
> Idea:
>
> Read data from file and try to spare conversation string-to-double.
>
> fscanfMat() won't do it, because the data does not contain only numerical
> values and "."-sign as decimal.
>
> So I tried csvRead.
>
> using the help I find:  separator :  a 1-by-1 matrix of strings, the
> field separator used.
>
>
>
> Note:   STRINGS   = plural.
>
>
>
> So I wonder if it is possible to have more than one separator here.
>
>
>
> BR
>
> Philipp
>
>
>
> mclose( :-) )
>
>
>
>
>
> ___
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>


-- 
In Kanada is' ka' na' da. Sonst wär' Kanada Jemanda.

There we have the salad.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Input/output of tabulated data

2016-10-14 Thread Lester Anderson
Hello,

Quick query. If I have a data file containg three columns e.g.

Long Lat gravity
12 2 34.4
20 4 60.3
30 6 23.7

I want to read column 3 (gravity) to process and then write the
results back out as:
gravity_processed = f(gravity)

Long Lat gravity_processed
12 2 g1
20 4 g2
30 6 g3 etc.

Is there a simple way of doing this?

Thanks
Lester
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] using csvRead

2016-10-14 Thread Serge Steer

you can use the mfscanf function:

u=mopen("myfile","r");
h=mfscanf(1,u,"%s\n");
r=mfscanf(-1,u,"%d.%d.%d, %d:%d:%f, %f, %f\n");
mclose(u)

Serge Steer

Le 14/10/2016 à 00:08, Philipp Mühlmann a écrit :

Dear Scilab users,

having a data file (*.cvs) containg following format:


HEADER-Line
dd.mm., HH:MM:SS.MS , value01, value02

dd = day
mm = month
 = year

HH = hour
MM = minute
SS = second
Ms = milli second

ValueXY = numerical value

Is it possible to use cvsRead in such a way to define the separator 
beeing ',' and ':' at the same time?


Background:

desired Matrix after reading the file is

M = [dd mm  HH MM SS MS value1 value2]


Thank you,
Philipp


--
In Kanada is' ka' na' da. Sonst wär' Kanada Jemanda.

There we have the salad.


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users