Hello,
I try to import Excel File from PyGt simple and then read it with pandas but It doesn't work.
I have error message:
Do you have an idea of what is going wrong ? I had no problems doing this with Tkinter.
Thank you,
I try to import Excel File from PyGt simple and then read it with pandas but It doesn't work.
I have error message:
Error:Traceback (most recent call last):
File "c:/Users/burea/Desktop/PROG/PYTHON/EXFORUM.py", line 32, in openFile
df = pandas.read_excel(fileName)
File "C:\Users\burea\Anaconda3\lib\site-packages\pandas\io\excel\_base.py", line 304, in read_excel
io = ExcelFile(io, engine=engine)
File "C:\Users\burea\Anaconda3\lib\site-packages\pandas\io\excel\_base.py", line 824, in __init__
self._reader = self._engines[engine](self._io)
File "C:\Users\burea\Anaconda3\lib\site-packages\pandas\io\excel\_xlrd.py", line 21, in __init__
super().__init__(filepath_or_buffer)
File "C:\Users\burea\Anaconda3\lib\site-packages\pandas\io\excel\_base.py", line 344, in __init__
filepath_or_buffer, _, _, _ = get_filepath_or_buffer(filepath_or_buffer)
File "C:\Users\burea\Anaconda3\lib\site-packages\pandas\io\common.py", line 200, in get_filepath_or_buffer
raise ValueError(msg)
ValueError: Invalid file path or buffer object type: <class 'tuple'>
Below is my code so far, 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import pandas import sys from PyQt5.QtWidgets import QWidget, QMessageBox, QApplication, QDesktopWidget, QMainWindow, QAction, qApp, QApplication, QFileDialog class Window1(QMainWindow): def __init__( self ): super ().__init__() self .initUI() def initUI( self ): OpenF = QAction( 'Open' , self ) OpenF.triggered.connect( self .openFile) self .statusBar() menubar = self .menuBar() fileMenu = menubar.addMenu( 'File' ) fileMenu.addAction(OpenF) self .resize( 800 , 600 ) self .setWindowTitle( 'Mapping' ) self .show() def openFile( self ): fileName = QFileDialog.getOpenFileName( self , 'OpenFile' ," ", " Excel ( * .xls * .xlsx)") df = pandas.read_excel(fileName) if __name__ = = '__main__' : app = QApplication(sys.argv) ex = Window1() sys.exit(app.exec_()) |
Thank you,