Xlrd modul - syntax error - read excel

Hello pyRevit friends,

While testing xlrd and xlsxwriter i have syntax error when trying to read a file that I just wrote with the xlsxwriter.

What could be the problem?

 File "C:\Users\nyk060\AppData\Roaming\pyRevit-Master\site-packages\xlrd\__init__.py", line 135, in open_workbook
 File "C:\Users\nyk060\AppData\Roaming\pyRevit-Master\site-packages\xlrd\xlsx.py", line 828, in open_workbook_2007_xml
 File "C:\Users\nyk060\AppData\Roaming\pyRevit-Master\site-packages\xlrd\xlsx.py", line 450, in process_stream_findall
 File "xml\etree\ElementTree.py", line 1182, in parse
 File "xml\etree\ElementTree.py", line 656, in parse
 File "xml\etree\SimpleXMLTreeBuilder.py", line 84, in feed
 File "xmllib.py", line 172, in feed
 File "xmllib.py", line 268, in goahead
 File "xmllib.py", line 795, in syntax_error
xmllib.Error: Syntax error at line 2: illegal character in content
import xlrd
xlrd.open_workbook(filepath)

Most probably the encoding of your text written
Accents and German letters?
Try first text without any accents or ‘special letters’

Hello @Jean-Marc

You are right there are some characters like “ä”

So that means I just cant use the pyrevit module, what are my options then to read an .xlsx file?

I tried to st an encoding when reading but it didn´t work either.

xlwb = xlrd.open_workbook(filepath, encoding_override="utf-8")

Hi @Gerhard.P
I also incurred in this problem a while ago, you can read about it in this github issue

TL;DR: try to change the ironpython engine version to something else

2 Likes