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