Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError bug in readxl #31

Closed
Darcy-C opened this issue Jan 27, 2021 · 3 comments
Closed

KeyError bug in readxl #31

Darcy-C opened this issue Jan 27, 2021 · 3 comments

Comments

@Darcy-C
Copy link

Darcy-C commented Jan 27, 2021

Pylightxl Version:1.51
Python Version:3.8.3
Office Version: LibreOffice 7.0.4.2

Summary of Bug/Feature: KeyError Bug

Traceback:

File "... ...\pylightxl\pylightxl.py", line 135, in readxl
    worksheet = ordered_ws[order]
KeyError: 1

Suggestion for fix:

def readxl(fn, ws=None):
        ... ...
        # get all worksheets
        for order in range(1, len(ordered_ws) + 1):      ---->   for order in ordered_ws.keys():
             worksheet = ordered_ws[order]
        ... ...

I found ordered_ws is {2: 'sheet1', 3: 'sheet2', 4: 'sheet3'}
It seems like the start number is 2 instead of 1.
so I do that change, that worked for me.
I am using LibreOffice to edit this xlsx file. So maybe there is some bug in LibreOffice ( or in pylightxl ).

Thanks :)

@Darcy-C
Copy link
Author

Darcy-C commented Jan 27, 2021

I find it's a duplicate issue. I close it.
issue page

@Darcy-C Darcy-C closed this as completed Jan 27, 2021
@PydPiper
Copy link
Owner

PydPiper commented Jan 27, 2021 via email

@Darcy-C
Copy link
Author

Darcy-C commented Jan 29, 2021

hi there, can you try to upgrade to v1.52 and see if that fixes your issue?
On Wed, Jan 27, 2021 at 7:53 AM Darcy @.***> wrote: Pylightxl Version:1.51 Python Version:3.8.3 Office Version: LibreOffice 7.0.4.2 Summary of Bug/Feature: KeyError Bug Traceback: File "......\pylightxl\pylightxl.py", line 135, in readxl worksheet = ordered_ws[order] KeyError: 1 Suggestion for fix: def readxl(fn, ws=None): ... ... # get all worksheets for order in range(1, len(ordered_ws) + 1): ----> for order in ordered_ws.keys(): worksheet = ordered_ws[order] ... ... I found ordered_ws is {2: 'sheet1', 3: 'sheet2', 4: 'sheet3'} It seems like the start number is 2 instead of 1. so I do that change, that worked for me. I am using LibreOffice to edit this xlsx file. So maybe there is some bug in LibreOffice. Thanks :) — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#31>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIOU6F2YE3PHEAU47KW2UTDS4AZGDANCNFSM4WVPXKPA .
-- Best, Viktor Kis

Thank you. v1.52 fixes my issue :>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants