X-Git-Url: http://iramuteq.org/git?a=blobdiff_plain;f=tableau.py;h=5760ad74e0e0f685f711f6f9a64e2f269377fa57;hb=11a360f9b1d2dc97a406378cd4b49ec3b71de2a0;hp=321c6ad344b166694862b923f2776f7786cb8910;hpb=eaa044d1147e26b82942ce56d5965c83fdddf069;p=iramuteq diff --git a/tableau.py b/tableau.py index 321c6ad..5760ad7 100644 --- a/tableau.py +++ b/tableau.py @@ -64,7 +64,7 @@ def UpdateDico(Dico, word, line): Dico[word][1].append(line) else: Dico[word] = [1, [line]] - + def copymatrix(tableau): log.info('copy matrix') copymat = Tableau(tableau.parent, parametres = tableau.parametres) @@ -212,7 +212,7 @@ class Tableau() : self.linecontent = [[val.replace('"','').replace(';',' ').replace('\t', ' ').strip() for val in line] for line in self.linecontent] def write_csvfile(self) : - with open(self.parametres['csvfile'], 'w') as f : + with open(self.parametres['csvfile'], 'w', encoding='utf8') as f : f.write('\n'.join(['\t'.join(line) for line in self.csvtable])) def make_tmpfile(self) : @@ -238,7 +238,7 @@ class Tableau() : self.write_csvfile() def read_csvfile(self): - with codecs.open(self.parametres['csvfile'], 'r', self.parametres['syscoding']) as f: + with open(self.parametres['csvfile'], 'r', encoding='utf8') as f: self.csvtable = [line.split('\t') for line in f.read().splitlines()] self.linecontent = [line[1:] for line in self.csvtable] self.linecontent.pop(0) @@ -290,11 +290,12 @@ class Tableau() : return [[val, self.actives[val][0]] for val in self.actives] def make_listactives(self) : - self.listactives = [val for val in self.actives if val != 'NA' and self.actives[val] >= self.parametres['mineff']] + print(self.actives, self.parametres['mineff']) + self.listactives = [val for val in self.actives if val != 'NA' and self.actives[val][0] >= self.parametres['mineff']] def write01(self, fileout, dico, linecontent) : if self.listactives is None : - self.listactives = [val for val in dico if val != 'NA' and dico[val] >= self.parametres['mineff']] + self.listactives = [val for val in dico if val != 'NA' and dico[val][0] >= self.parametres['mineff']] out = [['0' for forme in self.listactives] for line in linecontent] for i, forme in enumerate(self.listactives) : for line in dico[forme][1] : @@ -302,7 +303,7 @@ class Tableau() : #out = [[self.rownames[i]] + out[i] for i in range(len(linecontent))] #out.insert(0,[self.idname] + self.listactives) out.insert(0, self.listactives) - with open(fileout, 'w') as f : + with open(fileout, 'w', encoding='utf8') as f : f.write('\n'.join([';'.join(line) for line in out])) def make_01_from_selection(self, listact, listsup = None, dowrite = True) : @@ -330,15 +331,15 @@ class Tableau() : #table = [[self.rownames[i]] + table[i] for i in range(len(self.rownames))] #table.insert(0, [self.idname] + self.listactives) table.insert(0, self.listactives) - with open(fileout, 'w') as f: + with open(fileout, 'w', encoding='utf8') as f: f.write('\n'.join([';'.join(line) for line in table])) def printtable(self, filename, Table, sep = ';'): - with open(filename, 'w') as f : + with open(filename, 'w', encoding='utf8') as f : f.write('\n'.join([sep.join(line) for line in Table])) def buildprofil(self) : - with open(self.pathout['uce'], 'r') as filein : + with open(self.pathout['uce'], 'r', encoding='utf8') as filein : content = filein.readlines() content.pop(0) lsucecl = []