Exemple #1
0
 def table_handle(self):
     """Insert Table"""
     iter_insert = self.dad.curr_buffer.get_iter_at_mark(self.dad.curr_buffer.get_insert())
     ret_ok, ret_csv = self.dialog_tablehandle(_("Insert Table"), True)
     if not ret_ok: return
     if not ret_csv:
         self.table_insert(iter_insert)
     else:
         filepath = support.dialog_file_select(filter_pattern=["*.csv"],
                                               filter_name=_("CSV File"),
                                               curr_folder=self.dad.pick_dir,
                                               parent=self.dad.window)
         if filepath != None:
             self.dad.pick_dir = os.path.dirname(filepath)
             support.text_file_rm_emptylines(filepath)
             file_descriptor = open(filepath, 'r')
             reader = UnicodeReader(file_descriptor)
             table_matrix = []
             row = reader.next()
             while row:
                 table_matrix.append(row)
                 row = reader.next()
             file_descriptor.close()
             table_matrix.append(table_matrix.pop(0))
             self.table_insert(iter_insert, {'col_min': cons.TABLE_DEFAULT_COL_MIN,
                                             'col_max': cons.TABLE_DEFAULT_COL_MAX,
                                             'matrix': table_matrix})
Exemple #2
0
 def table_handle(self):
     """Insert Table"""
     iter_insert = self.dad.curr_buffer.get_iter_at_mark(
         self.dad.curr_buffer.get_insert())
     ret_ok, ret_csv = self.dialog_tablehandle(_("Insert Table"), True)
     if not ret_ok: return
     if not ret_csv:
         self.table_insert(iter_insert)
     else:
         filepath = support.dialog_file_select(
             filter_pattern=["*.csv"],
             filter_name=_("CSV File"),
             curr_folder=self.dad.pick_dir_csv,
             parent=self.dad.window)
         if filepath != None:
             self.dad.pick_dir_csv = os.path.dirname(filepath)
             support.text_file_rm_emptylines(filepath)
             file_descriptor = open(filepath, 'r')
             reader = UnicodeReader(file_descriptor)
             table_matrix = []
             row = reader.next()
             while row:
                 table_matrix.append(row)
                 row = reader.next()
             file_descriptor.close()
             table_matrix.append(table_matrix.pop(0))
             self.table_insert(
                 iter_insert, {
                     'col_min': cons.TABLE_DEFAULT_COL_MIN,
                     'col_max': cons.TABLE_DEFAULT_COL_MAX,
                     'matrix': table_matrix
                 })