Search code examples
excelcsvpyqtxlsfilepicker

Open a Datafile(csv,xls,xlsx,ods, etc) using "FILEPICKER" python?


I got to know how to open a data file when we know the name and type of the file but how do we code to pick a file with file picker?

import pyexcel as pe  
records = pe.get_records(file_name="your_file.xls")  
for record in records:  
     print("%s is aged at %d" % (record['Name'], record['Age']))

Solution

  • I got the problem, Now this code runs!

    filters = (
                'Data Files (*.csv *.txt *.xls *.xml *.xlsx *.xlsm)',
            )
            path, filter = QtGui.QFileDialog.getOpenFileNameAndFilter(
                self, 'Open File', '', ';;'.join(filters))