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] 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 <clement.da...@scilab-enterprises.com>; Users mailing list for Scilab <users@lists.scilab.org> 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
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
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
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
Re: [Scilab-users] read format
with s given as follow s=['01/03/2015 00:01:00;5.49;1' '01/03/2015 00:01:01;5.9;1' '01/03/2015 00:01:11;4.9;1'] The following instructions returns the expexted results msscanf(-1,s,"%*s %*2s%*[:]%*2s%*[:]%*2s%*[;]%g[^;]%*[;]") But I do not succeed if the data are stored in a file u=mopen("","r") mfscanf(-1,u,"%*s %*2s%*[:]%*2s%*[:]%*2s%*[;]%g[^;]%*[;]") returns an error I think a C format specialist could be able to find my error Serge 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 ? > Thank you for your help. > JP Grivet > ___ > 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, 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
[Scilab-users] read format
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 ? Thank you for your help. JP Grivet ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] read format
Hello, 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
Re: [Scilab-users] read format
Hello, Perhaps this could help (there is probably a more direct way to do it) str1="00:01:00;5.49;1"; str2=strchr(str1,';'); //str2= ";5.49;1" str3=strtok(str2,';'); // str3 = "5.49" d = strtod(str3); Regards Guylaine -Message d'origine- De : users [mailto:users-boun...@lists.scilab.org] De la part de grivet Envoyé : lundi 12 octobre 2015 14:27 À : users@lists.scilab.org Objet : [Scilab-users] read format 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 ? Thank you for your help. JP Grivet ___ 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
Le 12/10/2015 18:07, Clément David a écrit : M = csvRead('/tmp/sample.csv', ';', "double"); values = M(:,2); Indeed, or simply M = csvRead(theFileName, ';'); Without trying, i thought that meeting the date "01/03/2015 00:01:00;" would yield an error. But it is managed softly: it yields %nan instead. Scilab is great when it manages things softly :) This is why ieee(2) would be a soft default ;) Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users