+ def doanalyse(self):
+ select = self.parametres['colsel']
+ freq = self.tableau.countmultiple(select)
+ tot = sum([freq[forme][0] for forme in freq])
+ freq = [[forme, freq[forme][0], repr(round((float(freq[forme][0])/tot)*100, 2)),repr(len(list(set(freq[forme][1])))), repr(round((float(len(list(set(freq[forme][1]))))/self.tableau.rownb)*100,2))] for forme in freq]
+ freq = sorted(freq, key=itemgetter(1), reverse=True)
+ freq = [[line[0], repr(line[1]), line[2], line[3], line[4]] for line in freq]
+ freq.insert(0, ['mod', 'freq', 'percent of total', 'row number', 'percent of rows'])
+ self.freq = freq
+ with open(self.pathout['frequences.csv'], 'w') as f :
+ f.write('\n'.join(['\t'.join(line) for line in freq]))
+ self.rscript = FreqMultiScript(self)
+ self.rscript.make_script()
+ self.doR(self.rscript.scriptout)
+ self.dolayout()
+
+ def dolayout(self):
+ pretexte = '''<html>
+ <meta http-equiv="content-Type" content="text/html; charset=%s" />
+ <body>\n<h1>Fréquences</h1>
+ <a name="deb"></a><br>
+ ''' % self.parent.SysEncoding
+ txt = """
+ <table>\n<tr><td>\n
+ <table border=1><tr><td>
+ """
+ txt += '</td></tr><tr><td>'.join(['</td><td>'.join(line) for line in self.freq]) + '</td></tr></table></td></tr>'
+ txt += '<tr><td><img src="%s" alt="graph"/></td><td><img src="%s" alt="graph"/></td></tr></table>' % (os.path.basename(self.pathout['barplotfreq.png']), os.path.basename(self.pathout['barplotrow.png']))
+ txt += "</body>\n</html>"
+ with open(self.pathout['resultats.html'], 'w') as f :
+ f.write(pretexte + txt)