Issue
How to check if qTableWidget has empty cells and if has, turn those empty in 0(zero)?
With this I import data from qtablewidget table_Level_N
and turn them in array array
, if array
has 0 - code execution stops and print out error message in textedit:
self.ui.textEdit_status_N.clear()
array = []
for i in range(self.ui.table_Level_N.rowCount()):
row = []
array.append(row)
for j in range(1,6):
item = self.ui.table_Level_N.item(i,j)
if item:
try:
row.append(float(item.text()))
except TypeError:
row.append(0)
else:
row.append(0)
if np.all(array):
[some operation]
else: self.ui.textEdit_status_N.append("Error: array has zero")
Solution
add
except ValueError:
row.append(0)
right after TypeError
, it will turn all empty cells to 0
Answered By - Максим Александров
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.