code: def export(self, xformat='csv'):
          
          if self.annot is None:  # remove if buttons are disabled
              self.parent.statusBar().showMessage('No score file loaded')
              return
  
          if xformat == 'csv':
              filename = splitext(self.annot.xml_file)[0] + '.csv'
              filename, _ = QFileDialog.getSaveFileName(self, 'Export stages',
                                                        filename,
                                                        'Sleep stages (*.csv)')
          if 'remlogic' in xformat:
              filename = splitext(self.annot.xml_file)[0] + '.txt'
              filename, _ = QFileDialog.getSaveFileName(self, 'Export stages',
                                                        filename,
                                                        'Sleep stages (*.txt)')
          if filename == '':
              return
  
          self.annot.export(filename, xformat=xformat)
docs: action: export annotations to CSV.