Re: [Scilab-users] read format
It is possible to achieve what you want using the following instruction. It is a little tricky, may be a C format expert can do it in a more simple way. u=mopen("",'r') x=mfscanf(-1,u,"%*s %*2s%*[:]%*2s%*[:]%*2s%*[;]%g%*s"); mclose(u) Serge Steer Le 13/10/2015 16:19, sgoug...@free.fr a écrit : > Hello, > > - Mail original - >> De: "CHEZE David 227480" >> >> .../... Would you need to get the timestamps data, you may call csvRead with >> "string" conversion and process the first column of the matrix of string to >> retrieve numeric value fields. > For this part, using mfscanf() as suggested by Serge will be more > straightforward, instead of csvRead(). > > Samuel > ___ > 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
Re: [Scilab-users] read format
Hello, - Mail original - >De: "CHEZE David 227480" > >.../... Would you need to get the timestamps data, you may call csvRead with >"string" conversion and process the first column of the matrix of string to >retrieve numeric value fields. For this part, using mfscanf() as suggested by Serge will be more straightforward, instead of csvRead(). Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] read format
But you said you were just interested in the last two numeric values : with double conversion into csvRead call it's the fastest way to get the relevant information and process it further. Would you need to get the timestamps data, you may call csvRead with "string" conversion and process the first column of the matrix of string to retrieve numeric value fields. Cheers, David Chèze -Message d'origine- De : users [mailto:users-boun...@lists.scilab.org] De la part de grivet Envoyé : mardi 13 octobre 2015 12:09 À : Clément David ; Users mailing list for Scilab Objet : Re: [Scilab-users] read format Your suggestion does not work for me. Here is what I get: -->M = csvRead('dataN.txt', ';', "double"); -->M(1:10,:) ans = Nan5.491. Nan5.491. Nan5.481. Nan5.481. Nan5.481. which seems to check with the help for csvRead: When the input argument "conversion" is equal to "double", the non-numeric fields within the .csv (e.g. strings) are converted into NaN. Thank you for your time and help. JP Grivet > Hello, > > Well in fact the `evstr` call is not needed if you parse the csv and > interpreting directly the values as "double" using : > > M = csvRead('/tmp/sample.csv', ';', "double"); values = M(:,2); > > Regards, > > -- > Clément > > Le lundi 12 octobre 2015 à 18:00 +0200, grivet a écrit : >> Thank you Samuel, this works like a charm, even though the last step >> (evstr) takes a couple of minutes (8 lines!). >> For a completely different solution: read the file into emacs, define >> a rectangle of width 20 chars and height the whole file, delete this >> rectangle, search for ".1" and erase every occurence of this string. >> Thanks to everybody, >> JP Grivet >> >>> Le 12/10/2015 14:26, grivet a écrit : Hello, I have a data file of about 80k lines. A typical line looks like this: 01/03/2015 00:01:00;5.49;1 (date time; value;parameter). I am only interested in the field "value", which can be 3 or 4 characters wide (i.e. 5.49 or 5.4). How can I extract the desired data from this file ? >>> . >>> Likely with >>> M = csvRead(TheFileName, ";", ".", "string"); values = >>> evstr(M(:,2)); >>> >>> Samuel Gougeon >>> >> ___ >> 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 ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] read format
Your suggestion does not work for me. Here is what I get: -->M = csvRead('dataN.txt', ';', "double"); -->M(1:10,:) ans = Nan5.491. Nan5.491. Nan5.481. Nan5.481. Nan5.481. which seems to check with the help for csvRead: When the input argument "conversion" is equal to "double", the non-numeric fields within the .csv (e.g. strings) are converted into NaN. Thank you for your time and help. JP Grivet Hello, Well in fact the `evstr` call is not needed if you parse the csv and interpreting directly the values as "double" using : M = csvRead('/tmp/sample.csv', ';', "double"); values = M(:,2); Regards, -- Clément Le lundi 12 octobre 2015 à 18:00 +0200, grivet a écrit : Thank you Samuel, this works like a charm, even though the last step (evstr) takes a couple of minutes (8 lines!). For a completely different solution: read the file into emacs, define a rectangle of width 20 chars and height the whole file, delete this rectangle, search for ".1" and erase every occurence of this string. Thanks to everybody, JP Grivet Le 12/10/2015 14:26, grivet a écrit : Hello, I have a data file of about 80k lines. A typical line looks like this: 01/03/2015 00:01:00;5.49;1 (date time; value;parameter). I am only interested in the field "value", which can be 3 or 4 characters wide (i.e. 5.49 or 5.4). How can I extract the desired data from this file ? . Likely with M = csvRead(TheFileName, ";", ".", "string"); values = evstr(M(:,2)); Samuel Gougeon ___ 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
Re: [Scilab-users] Get back the name of a function given as argument
My bad, I've just realised that - this routine will actually give the name of the last copy of the function (in case of multiple imbricated function calls), - besides, a simpler solution consists in using the name of the local copy of the function. deff('y = fun(x)','y = x^2'); deff('y = f(x)','y = x'); deff('minimize(f)','disp(evstr(''f(2)''))'); minimize(f) // displays 2 minimize(fun) // displays 4 Le 13.10.2015 08:44, Pierre Vuillemin a écrit : Hi Samuel, Thank you for the answer. I have finally came up with this routine : function funName = sopi_retrieveFunName(f) varList = who_user(%f); for i = 2:size(varList,1) // "f" is the local copy of the function and is the first one in the varList, it must be discarded varName = varList(i); execstr("var = "+varName); if var == f then funName = varName; break; end end endfunction It retrieves the name of the function given as argument by comparing it to the user's variables. It (very) far from being elegant, but it seems to work. Will there be a better way to achieve that with Scilab 6 ? Pierre Le 12.10.2015 21:02, Samuel Gougeon a écrit : Hi Pierre, Le 12/10/2015 16:46, Pierre Vuillemin a écrit : Hi all, I am building some optimisation tools, and in this context, I was wondering if it was possible to get back the name of a function given as argument of another function. More specifically, consider the function 'fun' defined as deff('[f,g] = fun(x)','f = x^2;g = 2*x'); and an optimisation routine "minimize" which first argument is a function. Is there a way to get back the name of the function "fun" when calling "minimize(fun)" ? I am afraid that, with 5.5.2, you have to use something like minimize("thefun") instead, with function argout = minimize(fun,...) execstr("fun="+fun); ... endfunction Samuel ___ 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 ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Get back the name of a function given as argument
Hi Samuel, Thank you for the answer. I have finally came up with this routine : function funName = sopi_retrieveFunName(f) varList = who_user(%f); for i = 2:size(varList,1) // "f" is the local copy of the function and is the first one in the varList, it must be discarded varName = varList(i); execstr("var = "+varName); if var == f then funName = varName; break; end end endfunction It retrieves the name of the function given as argument by comparing it to the user's variables. It (very) far from being elegant, but it seems to work. Will there be a better way to achieve that with Scilab 6 ? Pierre Le 12.10.2015 21:02, Samuel Gougeon a écrit : Hi Pierre, Le 12/10/2015 16:46, Pierre Vuillemin a écrit : Hi all, I am building some optimisation tools, and in this context, I was wondering if it was possible to get back the name of a function given as argument of another function. More specifically, consider the function 'fun' defined as deff('[f,g] = fun(x)','f = x^2;g = 2*x'); and an optimisation routine "minimize" which first argument is a function. Is there a way to get back the name of the function "fun" when calling "minimize(fun)" ? I am afraid that, with 5.5.2, you have to use something like minimize("thefun") instead, with function argout = minimize(fun,...) execstr("fun="+fun); ... endfunction Samuel ___ 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