SCILAB

SCILAB是一个类MATLAB软件,最近在做一个分齿算法,用到了它。

下面的代码是实现统计文本文件的某个字段功能:

less80cnt=0;
datestr="20140703"
writecontent="";
rtmp="";

fpath="F:\132 data\line5\20140701-20140705\5\x\"+datestr;
flst=findfiles(fpath,"*.txt");

for fidx=1:size(flst,"r")
    fcontent=csvRead(fpath+"\"+flst(fidx),"\t",[],"string");
    for ridx=1:size(fcontent,"r")
        if(fcontent(ridx,1)=="80"&(fcontent(ridx,8)=="0"|fcontent(ridx,9)=="0"|fcontent(ridx,10)=="0"|fcontent(ridx,11)=="0"))
            rtmp=fcontent(ridx,1)+ascii(9)+fcontent(ridx,2)+ascii(9)+fcontent(ridx,5)+ascii(9)+fcontent(ridx,8)+ascii(9)+fcontent(ridx,9)+ascii(9)+fcontent(ridx,10)+ascii(9)+fcontent(ridx,11)++ascii(10)+ascii(13);
            writecontent=[writecontent;rtmp];
            disp(rtmp);
            less80cnt=less80cnt+1;
        end
    end
end

writecontent=[writecontent;"The motor of less 80 tooth in " + fpath + " has " + string(less80cnt)];
write("D:\Users\RD\Desktop\"+datestr+".txt",writecontent);

输出结果如下:

 80	201407032151430500105	5	2190	0	2303	2303


 80	201407032151430500105	10	0	0	2616	2616


 80	201407032206520500105	1	1971	0	2106	2106


 80	201407032213250500105	9	2558	0	2581	2581


 80	201407032227520500105	1	1935	1935	2331	0


 80	201407032235170500105	4	2266	2266	0	0


 80	201407032242260500105	7	2167	0	2364	2364


 80	201407032249590500105	2	0	0	0	0


 80	201407032249590500105	12	0	0	0	0


 80	201407032257020500105	8	1979	1979	0	0


 80	201407032305380500105	3	2349	0	2491	2491


 80	201407032312150500105	8	2396	2396	0	0


 80	201407032319170500105	6	0	0	2020	2020


 The motor of less 80 tooth in F:\132 data\line5\20140701-20140705\5\x\20140703 
 has 266

Leave a Reply

Your email address will not be published. Required fields are marked *