How to convert OpenDocument spreadsheets to a pandas DataFrame?

Lamps1829 picture Lamps1829 · Jul 24, 2013 · Viewed 39k times · Source

The Python library can read Excel spreadsheets and convert them to a pandas.DataFrame with pandas.read_excel(file) command. Under the hood, it uses xlrd library which does not support ods files.

Is there an equivalent of pandas.read_excel for ods files? If not, how can I do the same for an Open Document Formatted spreadsheet (ods file)? ODF is used by LibreOffice and OpenOffice.

Answer

Will Ayd picture Will Ayd · Jul 4, 2019

This is available natively in pandas 0.25. So long as you have odfpy installed (conda install odfpy OR pip install odfpy) you can do

pd.read_excel("the_document.ods", engine="odf")