I've programmed a GUI for, among other things, reading an excel data and showing the values. I'm using xlrd for this. I've tried it with for loop through a constant number of rows and columns (I know how big the data is) and it works how it should. I'm using PyCharm for it.
Next step should be a while loop, which can read any data, doesn't matter how big it is. For this reason I've come to an idea: - I'm checking if there is any blank row or column - If there's more than 10 blank rows or columns after each other, the programm should stop doing the while loop
The problem: my method setDatei() is opening a file and loading the values of every cell at the same time. It works for the first case only if I set as counter the last row/column of this file. If it's only 1 number above, the program will return: "Process finished with exit code -1073740791 (0xC0000409)". The same happens trying to do the second case with while loop.
I've tried to understand this: Process finished with exit code -1073741571 or that: How to overcome Stack Size issue with Visual Studio (running C codes with big array) But I think I haven't just understood it. It should work on every pc, not only on mine, so changing any pc settings is not wishable.
Case 1: works
def setDatei(self): #Programmauswahl
fileName, _ = QtWidgets.QFileDialog.getOpenFileName(None, "Waehle das Programm aus", "",
"Excel Files *.xlsx *.xls") # Frage nach Datei
if fileName: # Wenn der Benutzer eine Datei gibt
print(fileName)
self.setLine.setText(fileName) # zeigt den Dateinamen in der Leiste oben links
####Öffnet die Datei und lädt die Werte
workbook = xlrd.open_workbook(fileName)
worksheet = workbook.sheet_by_index(0)
# 16 Zeilen, 11 Spalten
n = 0
m = 0
for i in range(0, 16): # for-Schleife, um alle Zellen auszulesen und übertragen
m = 0
a = str(worksheet.cell(n, m).value)
for i in range(0, 11):
a = str(worksheet.cell(n, m).value)
self.tableWidget.setItem(n, m, QtWidgets.QTableWidgetItem(a))
m = m + 1
n = n + 1
Case 2: doesn't work
def setDatei(self): #Programmauswahl
fileName, _ = QtWidgets.QFileDialog.getOpenFileName(None, "Waehle das Programm aus", "",
"Excel Files *.xlsx *.xls") # Frage nach Datei
if fileName: # Wenn der Benutzer eine Datei gibt
print(fileName)
self.setLine.setText(fileName) # zeigt den Dateinamen in der Leiste oben links
####Öffnet die Datei und lädt die Werte
workbook = xlrd.open_workbook(fileName)
worksheet = workbook.sheet_by_index(0)
lineThreshold = 10
columnThreshold = 10
row = 0
lineEmptyCounter = 0
while True:
col = 0
columnEmptyCounter = 0
lineEmpty = True
while True:
value = str(worksheet.cell(row, col).value)
if value is None:
columnEmptyCounter += 1
else:
lineEmpty = False
columnEmptyCounter = 0
self.tableWidget.setItem(row, col, QtWidgets.QTableWidgetItem(value))
if columnEmptyCounter >= columnThreshold:
break
else:
col = col + 1
if lineEmpty:
lineEmptyCounter += 1
else:
lineEmptyCounter = 0
if lineEmptyCounter >= lineThreshold:
break
else:
row = row+1
Process finished with exit code -1073740791 (0xC0000409). The programm closes without any information. I've no idea where to start. If you need further details, just let me know.