1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2008-2011 Pierre Ratinaud
12 def OnOpen(self, type):
14 wildcard = u"Fichiers supportés|*.ods;*.xls;*.csv;*.txt|Openoffice Clac|*.ods|Fichier excel|*.xls|Fichier csv|*.csv|Fichier texte|*.txt|Tous les fichiers|*"
16 wildcard = "Fichier texte|*.txt|Tous les fichiers|*"
17 elif type == "Analyse":
18 wildcard = "Fichier analyse|*.ira"
19 defaultDir = self.PathPath.get('PATHS', 'lastpath')
20 if defaultDir.strip() == '':
21 defaultDir = self.UserConfigPath.replace('.iramuteq','')
23 self, message="Choisissez un fichier", defaultDir=defaultDir,
24 defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.CHANGE_DIR)
26 if dlg.ShowModal() == wx.ID_OK :
27 fileName = dlg.GetFilename()
30 self.PathPath.set('PATHS', 'lastpath', os.path.dirname(path[0]))
39 elif type == "Analyse":
42 def getfileextension(file) :
43 return os.path.splitext(file)[1]
45 def get_table_param(self, filename) :
46 if getfileextension(filename) == '.csv':
47 dlg = dialog.FileOptionDialog(self, -1, u"Format du fichier", sep=True, size=(350, 200),
48 style=wx.DEFAULT_DIALOG_STYLE)
52 self.tableau.parametre['colsep'] = dlg.colsep[dlg.choice3.GetSelection()]
53 self.tableau.parametre['txtsep'] = dlg.txtsep[dlg.choice4.GetSelection()]
54 if self.tableau.parametre['colsep'] == 'tabulation' :
55 self.tableau.parametre['colsep'] = '\t'
56 self.tableau.parametre['filetype'] = 'csv'
59 elif getfileextension(filename) == '.xls' :
60 dlg = dialog.FileOptionDialog(self, -1, u"Format du fichier", sep=False, sheet = True, size=(350, 200),
61 style=wx.DEFAULT_DIALOG_STYLE)
65 self.tableau.parametre['colsep'] = ';'
66 self.tableau.parametre['txtsep'] = '\"'
67 self.tableau.parametre['encodage'] = sys.getdefaultencoding()
68 self.tableau.parametre['sheetnb'] = dlg.spin1.GetValue()
69 self.tableau.parametre['filetype'] = 'xls'
72 elif getfileextension(filename) == '.ods':
73 dlg = dialog.FileOptionDialog(self, -1, u"Format du fichier", sep=False, size=(350, 200),
74 style=wx.DEFAULT_DIALOG_STYLE)
78 self.tableau.parametre['colsep'] = ';'
79 self.tableau.parametre['txtsep'] = '\"'
80 self.tableau.parametre['filetype'] = 'ods'
86 if dlg.radio_box_1.GetSelection() == 0:
87 self.tableau.firstrowiscolnames = True
89 self.tableau.firstrowiscolnames = False
90 if dlg.radio_box_2.GetSelection() == 0:
91 self.tableau.firstcolisrownames = True
93 self.tableau.firstcolisrownames = False
97 if '_mgr' in dir(ira) :
98 if not ira._mgr.GetPane('Text').IsShown() :
99 if ira.nb.GetPageCount() >= 1:
100 return ira.nb.GetPage(ira.nb.GetSelection())
108 def getCorpus(page) :
109 if 'corpus' in page.__dict__:
110 return copy(page.corpus)