lf = ['finalAnalysisReport_jf_oldci_stable_b_4bit.txt', 'finalAnalysisReport_jf_oldci_stable_b_6bit.txt','finalAnalysisReport_jf_oldci_stable_b_8bit.txt'] fd =[open(f,"r") for f in lf] lignes=[fdi.readlines()[7:] for fdi in fd] label = ["Frequency (Monobit)","Frequency within a Block","Runs","Longest Run of Ones in a Block","Binary Matrix Rank","Discrete Fourier Transform (Spectral)","Non-overlapping Template Matching*","Overlapping Template Matching","Maurer's \"Universal Statistical\"","Linear Complexity","Serial* (m=10)","Approximate Entropy (m=10)","Cumulative Sums (Cusum) *","Random Excursions *","Random Excursions Variant *"] endl="\\\\ \\hline \n" st="" #freq def traitenlignes(num1,num2): sti="" for l in lignes: #calcul des moyennes mv ms mv,ms=0,0 for j in range(num1,num2+1): stl=[] for x in l[j].split(" "): if x !='': stl += [x] idxdiv = 0 for i in range(len(stl)): if stl[i].find('/') != -1: idxdiv = i mv += float(stl[idxdiv-1]) rate = stl[idxdiv].split("/") ms += float(rate[0])/float(rate[1]) #sti += "& " + str(mv/(num2-num1+1))[:5] + " (" + str(ms/(num2-num1+1))[0:5] +")" sti += "& " + str(mv/(num2-num1+1))[:5] + "/" + str(round(100*ms/(num2-num1+1)))[0:2] return sti + endl def traite1ligne(numl): sti="" for l in lignes: stl=[] splitee = l[numl].split(" ") for x in l[numl].split(" "): if x !='': stl += [x] idxdiv = 0 for i in range(len(stl)): #print splitee[i],i if stl[i].find('/') != -1: idxdiv = i #print idxdiv r = str(round(float(stl[idxdiv].split("/")[0]))) #ti += "& " + stl[idxdiv-1][:5] + " (" + r[0:5]+")" sti += "& " + stl[idxdiv-1][:5] + "/" + r[0:2] return sti + endl st += label[0] + traite1ligne(0) st += label[1] + traite1ligne(1) st += label[2] + traite1ligne(4) st += label[3] + traite1ligne(5) st += label[4] + traite1ligne(6) st += label[5] + traite1ligne(7) st += label[6] + traitenlignes(8,155) st += label[7] + traite1ligne(156) st += label[8] + traite1ligne(157) st += label[9] + traite1ligne(185) st += label[10] + traitenlignes(185,186) st += label[11] + traite1ligne(187) st += label[12] + traitenlignes(2,3) st += label[13] + traitenlignes(159,166) st += label[14] + traitenlignes(167,184) print st