I want to parse excel document to lists in Python. Is there a python library which is helpful for this action? And what functions are relevant in that library?
Importing csv files in Python is 100x faster than Excel files. We can now load these files in 0.63 seconds. That's nearly 10 times faster! Python loads CSV files 100 times faster than Excel files.
You can easily import an Excel file into Python using Pandas. In order to accomplish this goal, you'll need to use read_excel. In this short guide, you'll see the steps to import an Excel file into Python using a simple example.
Further Reading. There's a lot more you can do with Excel files in your Python programs. For example, you can modify data in an existing Excel file, or you can extract the data you're interested in and generate an entirely new Excel file.
You're best bet for parsing Excel files would be the xlrd library. The python-excel.org site has links and examples for xlrd and related python excel libraries, including a pdf document that has some good examples of using xlrd. Of course, there are also lots of related xlrd questions on StackOverflow that might be of use.
One caveat with the xlrd library is that it will only work with xls
(Excel 2003 and earlier versions of excel) file formats and not the more recent xlsx
file format. There is a newer library openpyxl for dealing with the xlsx
, but I have never used it.
UPDATE: As per John's comment, the xlrd library now supports both xls
and xlsx
file formats.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With