From c8aad904a8e125f381d3e4e9022c87d9d28a2484 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 3 Apr 2024 15:53:19 +0000 Subject: [PATCH] 262-column-header (#264); closes #262 Co-authored-by: Dominik Demuth Reviewed-on: https://gitea.pkm.physik.tu-darmstadt.de/IPKM/nmreval/pulls/264 --- src/gui_qt/io/asciireader.py | 5 ++++- src/gui_qt/io/filereaders.py | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gui_qt/io/asciireader.py b/src/gui_qt/io/asciireader.py index 489c33d..ea4c980 100644 --- a/src/gui_qt/io/asciireader.py +++ b/src/gui_qt/io/asciireader.py @@ -132,7 +132,10 @@ class QAsciiReader(QtWidgets.QDialog, Ui_ascii_reader): self.ascii_table.setHorizontalHeaderLabels(map(str, range(1, self.ascii_table.columnCount() + 1))) if self.column_checkBox.isChecked() and self.line_spinBox.isEnabled(): header_line = self.reader.header[self.line_spinBox.value()-1] - self.ascii_table.setHorizontalHeaderLabels(header_line.split()) + header_line = header_line.strip('\n\t\r, ') + header_line = re.sub(r'[\t ;,]+', ';', header_line) + + self.ascii_table.setHorizontalHeaderLabels(header_line.split(';')) @QtCore.pyqtSlot(int, name='on_staggered_checkBox_stateChanged') def changestaggeredrange(self, state: int): diff --git a/src/gui_qt/io/filereaders.py b/src/gui_qt/io/filereaders.py index 808d96f..59b491a 100755 --- a/src/gui_qt/io/filereaders.py +++ b/src/gui_qt/io/filereaders.py @@ -51,6 +51,7 @@ class QFileReader(QtCore.QObject): if not isinstance(fname, list): fname = [fname] + status = QtWidgets.QDialog.Accepted for f in fname: f = Path(f) dtype = self.guess_type(f) @@ -61,9 +62,9 @@ class QFileReader(QtCore.QObject): try: # If QAsciiReader.skip = True it accepts automatically and returns None - status = r(f).exec() - if status == QtWidgets.QDialog.Rejected and isinstance(r, QAsciiReader): + if status == QtWidgets.QDialog.DialogCode.Rejected and isinstance(r, QAsciiReader) and self.reader['txt'].skip: break + status = r(f).exec() except AttributeError: pass