[Scilab-users] [EXTERNAL] Count specific values in text file
P M
p.muehlmann at gmail.com
Tue Feb 11 15:40:50 CET 2020
Hi,
is this what you're looking for?
// path to the txt filepath = 'pathToFile'
// read the file as stringpiAsString = csvRead(path, [],['.'],'string')
// split the string at the decimal[piAsString] = strsplit(piAsString,'.');
// just get the digitspiDigits = strtod(strsplit(piAsString(2)));
// search: how often does appears a certain value in a specific range
within the digitssearchRange = 100;searchVal = 1;
[locations] = find(piDigits(1:searchRange) == searchVal);
printf("The number %d appears %d times in the first %d digits of
Pi\n",searchVal,length(locations),searchRange) ;printf("The number %d
appears at following locations: \n", searchVal);disp(locations');
Best regards,
Philipp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20200211/aa013fd0/attachment.htm>
More information about the users
mailing list