xlrd asserts on my .xls at open_workbook

135 views
Skip to first unread message

Diego J.

unread,
Jun 1, 2012, 10:10:55 PM6/1/12
to python-excel
Hello people.

I have this one excel file full of macros provided for the company
which I work which is not being read by xlrd.
I want to automate the reading, processing and maybe also writing of
this excel file.
I can not edit the macros because it is password protected for the
developer in our company.
This file has also cells which are "protected" and doesnt allows me to
edit them, but only through some others non-protected.

If I try to load it directly, I get this result:

NOTE *** Ignoring non-worksheet data named u'Macros' (type 0x06 =
Visual Basic module)
Traceback (most recent call last):
File "C:\Users\Administrador\Desktop\Test Testsight\ict2pdf
\ict2pdf.py", line 18, in <module>
xlBook = xlrd.open_workbook(xlFilename)
File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 481, in
open_workbook
bk.get_sheets()
File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 1067, in
get_sheets
self.get_sheet(sheetno)
File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 1058, in
get_sheet
sh.read(self)
File "C:\Python27\lib\site-packages\xlrd\sheet.py", line 1082, in
read
saved_obj = self.handle_obj(data)
File "C:\Python27\lib\site-packages\xlrd\sheet.py", line 1888, in
handle_obj
assert pos == data_len
AssertionError

Process completed, Exit Code 1.
Execution time: 00:00.679


If I then open it with LibreOffice and save it as .xls (97/2000/xp),
then I do can read the contents.
I don't understand why is failing.
What can I do to help you to discover this without sending the excel
file which is copyrighted.

Cheers
Diego

John Machin

unread,
Jun 3, 2012, 7:41:04 PM6/3/12
to python...@googlegroups.com


On Saturday, June 2, 2012 12:10:55 PM UTC+10, Diego J. wrote:
 
  File "C:\Python27\lib\site-packages\xlrd\sheet.py", line 1888, in
handle_obj
    assert pos == data_len
AssertionError

 It's rather difficult and tedious to attempt debugging a problem like that without direct access to a copy of the file. I have just now committed a fix to a probably-related problem -- see https://github.com/python-excel/xlrd ... I suggest that you get a copy of that and try it out and tell me the result.

By the way, "copyright" doesn't mean "can't let people read it" (otherwise the new book trade couldn't exist). Please consider to your boss about an NDA (non-disclosure agreement).

Diego Jacobi

unread,
Jun 4, 2012, 8:53:52 PM6/4/12
to python...@googlegroups.com
Genius !
You had it !

I have downloaded todays version from github.
File named as python-excel-xlrd-0.7.6-15-gdf92535.zip

Installed it in windows and it worked with the original .xls file.

The only difference that I see is this warning:
"NOTE *** Ignoring non-worksheet data named u'Macros' (type 0x06 =
Visual Basic module)"
Which is harmless, as long as the Macros doesn't get edited.

Thanks !! John

Cheers.
Diego




2012/6/3 John Machin <sjma...@lexicon.net>:
> --
> You received this message because you are subscribed to the Google Groups
> "python-excel" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/python-excel/-/mYj3KGGfxOsJ.
>
> To post to this group, send an email to python...@googlegroups.com.
> To unsubscribe from this group, send email to
> python-excel...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/python-excel?hl=en-GB.
Reply all
Reply to author
Forward
0 new messages