nickmckay / LiPD-utilities

Input/output and manipulation utilities for LiPD files in Matlab, R and Python
http://nickmckay.github.io/LiPD-utilities/
GNU General Public License v2.0
29 stars 9 forks source link

Excel engine problems for Python3.9+ #84

Open elkezeller opened 2 years ago

elkezeller commented 2 years ago

I'm trying to make Excel files for all the Paleo data I use and then convert them to LiPD files. But when doing this I have trouble with the Excel engine used in LiPD.

I get the following error when using D = lipd.excel()

Found 1 Excel files
processing: LiPD_Herbert2010.xlsx
Failed to open Excel workbook: LiPD_Herbert2010, 'ElementTree' object has no attribute 'getiterator'

In Python 3.9+ xml.etree.ElementTree.Element.getiterator() has been depreciated. I got this info and a work around from a similar issue in Stack Overflow.

Workaround for people having the same problem:

import xlrd
xlrd.xlsx.ensure_elementtree_imported(False, None)
xlrd.xlsx.Element_has_iter = True

Possible fix: Add the engine option to the readExcel function. That way people can specify engine='openpyxl' this will solve the problem.