...
[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
17 class SplitMatrixFromVar(AnalyseMatrix):
18     def doparametres(self, dlg=None) :
19         if dlg is None :
20             return
21         else :
22             dial = FreqDialog(self.parent, -1, self.tableau.get_colnames(), u"Column", size=(350, 200))
23             dial.CenterOnParent()
24             val = dial.ShowModal()
25             if val == wx.ID_OK :
26                 self.parametres['colsel'] = dial.list_box_1.GetSelections()
27                 self.parametres['header'] = dial.header
28             else :
29                 self.parametres = None
30             dial.Destroy()
31                 
32     def doanalyse(self):
33         newtabs = self.tableau.splitfromvar(self.parametres['colsel'][0])
34         for mod in newtabs :
35             fout = self.tableau.pathout['%s.csv' % mod].replace(u'*','')
36             with open(fout, 'w') as f :
37                 f.write('\n'.join(['\t'.join(line) for line in newtabs[mod]]).encode(self.parent.syscoding))
38         print 'done!'