I’ve mentioned a few times on this blog (example) about the growing possibility for Python <> Excel interoperability. Here’s a simple task done in a way I wasn’t aware of (h/t — where else? — StackOverflow.)
Usually when combining Python and Excel I use specific packages like
xlsxwriter for a very rich suite of tools. It would be hard to find any Excel task that couldn’t be automated from these packages.
It would also be hard to get much data analysis done with
pandas, which does have some limited features for working with Excel. And apparently one of them is getting a list of worksheet names. This is all I really wanted to do and I had
pandas open anyway, so why not do it this way?
Usually my first move when working with an Excel file from
pandas is to read it in with
read_excel(). However, another option is
ExcelFile. Follow along with the below Jupyter notebook to see how it’s done:
I hope you can find
ExcelFile() when working with Python and Excel in a pinch.
How have you used these programs together? Do you have any questions about doing so? Let me know in the comments.