more correct lines preview in asciireader
This commit is contained in:
parent
267554b252
commit
e10b85b904
@ -98,15 +98,19 @@ class QAsciiReader(QtWidgets.QDialog, Ui_ascii_reader):
|
|||||||
|
|
||||||
@QtCore.pyqtSlot(int, name='on_preview_spinBox_valueChanged')
|
@QtCore.pyqtSlot(int, name='on_preview_spinBox_valueChanged')
|
||||||
def show_preview(self, line_no: int):
|
def show_preview(self, line_no: int):
|
||||||
preview, width = self.reader.make_preview(line_no)
|
preview, width, comments = self.reader.make_preview(line_no)
|
||||||
self.ascii_table.setRowCount(min(line_no, len(preview)))
|
self.ascii_table.setRowCount(min(line_no, len(preview)))
|
||||||
self.ascii_table.setColumnCount(width)
|
self.ascii_table.setColumnCount(width + 1)
|
||||||
|
|
||||||
for i, line in enumerate(preview):
|
for i, line in enumerate(preview):
|
||||||
|
comment_line = comments[i]
|
||||||
for j, field in enumerate(line):
|
for j, field in enumerate(line):
|
||||||
it = QtWidgets.QTableWidgetItem(field)
|
it = QtWidgets.QTableWidgetItem(field)
|
||||||
self.ascii_table.setItem(i, j, it)
|
self.ascii_table.setItem(i, j, it)
|
||||||
|
|
||||||
|
it = QtWidgets.QTableWidgetItem(comment_line)
|
||||||
|
self.ascii_table.setItem(i, len(line), it)
|
||||||
|
|
||||||
self.ascii_table.resizeColumnsToContents()
|
self.ascii_table.resizeColumnsToContents()
|
||||||
|
|
||||||
@QtCore.pyqtSlot(int, name='on_column_checkBox_stateChanged')
|
@QtCore.pyqtSlot(int, name='on_column_checkBox_stateChanged')
|
||||||
|
@ -19,10 +19,8 @@ class AsciiReader:
|
|||||||
self.fname = None
|
self.fname = None
|
||||||
self.header = []
|
self.header = []
|
||||||
self.lines = []
|
self.lines = []
|
||||||
self.num_data = []
|
|
||||||
self.delays = None
|
self.delays = None
|
||||||
self.width = []
|
self.width = []
|
||||||
self.num_width = []
|
|
||||||
self.line_comment = []
|
self.line_comment = []
|
||||||
self._last_read_pos = 0
|
self._last_read_pos = 0
|
||||||
|
|
||||||
@ -61,13 +59,12 @@ class AsciiReader:
|
|||||||
is_empty = len(line) == 0
|
is_empty = len(line) == 0
|
||||||
|
|
||||||
if not is_empty:
|
if not is_empty:
|
||||||
self.width.append(len(line))
|
|
||||||
self.lines.append(line)
|
self.lines.append(line)
|
||||||
if not line[0].startswith('#'):
|
self.width.append(len(line))
|
||||||
self.num_data.append(line)
|
else:
|
||||||
self.num_width.append(len(line))
|
self.lines.append('')
|
||||||
|
|
||||||
return self.lines, max(self.width)
|
return self.lines, max(self.width), self.line_comment
|
||||||
|
|
||||||
def look_for_delay(self, fname=None):
|
def look_for_delay(self, fname=None):
|
||||||
if fname is None:
|
if fname is None:
|
||||||
@ -105,7 +102,7 @@ class AsciiReader:
|
|||||||
raise ValueError(f'x is {type(x)} not int')
|
raise ValueError(f'x is {type(x)} not int')
|
||||||
|
|
||||||
if y is None:
|
if y is None:
|
||||||
y = list(range(1, max(self.num_width)))
|
y = list(range(1, max(self.width)))
|
||||||
|
|
||||||
cols = x + y + yerr
|
cols = x + y + yerr
|
||||||
with self.fname.open('rb') as fh:
|
with self.fname.open('rb') as fh:
|
||||||
@ -115,7 +112,7 @@ class AsciiReader:
|
|||||||
|
|
||||||
if raw_data.ndim == 1:
|
if raw_data.ndim == 1:
|
||||||
# only one row or column
|
# only one row or column
|
||||||
if len(self.num_data) == 1:
|
if len(self.lines) == 1:
|
||||||
# one row
|
# one row
|
||||||
raw_data = raw_data.reshape(1, -1)
|
raw_data = raw_data.reshape(1, -1)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user