multisplit
[iramuteq] / tabsplitvar.py
1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2008-2020 Pierre Ratinaud
4 #modification pour python 3 : Laurent Mérat, 6x7 - mai 2020
5 #License: GNU/GPL
6
7 #------------------------------------
8 # import des modules python
9 #------------------------------------
10 import os
11 import tempfile
12 from time import sleep
13
14 #------------------------------------
15 # import des modules wx
16 #------------------------------------
17 import wx
18
19 #------------------------------------
20 # import des fichiers du projet
21 #------------------------------------
22 from chemins import ffr, FFF
23 from analysematrix import AnalyseMatrix
24 from functions import exec_rcode, check_Rresult
25 from dialog import FreqDialog
26 from PrintRScript import PrintRScript
27 from tableau import Tableau
28
29
30 class SplitMatrixFromVar(AnalyseMatrix):
31
32     def doparametres(self, dlg=None) :
33         if dlg is None :
34             return
35         else :
36             dial = FreqDialog(self.parent, self.tableau.get_colnames(), "Column", size=(350, 200), showNA = False)
37             dial.CenterOnParent()
38             val = dial.ShowModal()
39             if val == wx.ID_OK :
40                 self.parametres['colsel'] = dial.m_listBox1.GetSelections()
41                 self.parametres['header'] = dial.header
42                 self.parametres['tohistory'] = False
43             else :
44                 self.parametres = None
45             dial.Destroy()
46
47     def doanalyse(self):
48         newtabs = self.tableau.splitfromvar(self.parametres['colsel'][0])
49         for mod in newtabs :
50             tab = Tableau(self.ira, os.path.join(self.tableau.pathout['%s.csv' % mod]).replace('*',''))
51             if not os.path.exists(tab.pathout.dirout) :
52                 os.mkdir(tab.pathout.dirout)
53             tab.linecontent = newtabs[mod]
54             tab.make_content_simple()
55             tab.parametres['matrix'] = tab.parametres['uuid']
56             self.ira.tree.OnItemAppend(tab.parametres, select = False)