-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: XLSB support #29836
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
Merged
Merged
ENH: XLSB support #29836
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
a4f2d22
initial xlsb support
Rik-de-Kort 62564cf
Import order fix for CI pass
Rik-de-Kort a7a8460
Initial tests
Rik-de-Kort d9be281
style fixes
Rik-de-Kort 8bf8c78
documentation
Rik-de-Kort cd95dce
forgot place to document
Rik-de-Kort 7a7390d
Fixed test issue with XLRDError
Rik-de-Kort 248ac12
Fix for unnamed column issue
Rik-de-Kort 6ea78de
style fix
Rik-de-Kort 44c5439
line up with upstream master
Rik-de-Kort 92c98cd
Merge branch 'master' of https://github.com/pandas-dev/pandas
Rik-de-Kort 64fa6f3
Fix broken xlrd test
Rik-de-Kort cb276e8
get docs to build
Rik-de-Kort 4ebcb48
Remove warning filter
Rik-de-Kort 71436a0
Merge branch 'master' of https://github.com/Rik-de-Kort/pandas
Rik-de-Kort 00cc66b
extended description update
Rik-de-Kort 4c81853
Merge branch 'master' of https://github.com/pandas-dev/pandas
Rik-de-Kort e85da03
Xlsb options instead of odf options
Rik-de-Kort 2348c3b
Add reference in whatsnew to docs
Rik-de-Kort d02a5a5
Make pyxlsb show up in install.rst and show_versions
Rik-de-Kort c71e021
Add pyxlsb to ci builds
Rik-de-Kort ae3f9ea
environment.yml update
Rik-de-Kort a410e51
Merge upstream master
Rik-de-Kort 7c9dcce
One update to environment.yml too many
Rik-de-Kort 4bd8400
Trying to fix build
Rik-de-Kort 43ab0fe
Merge upstream
Rik-de-Kort 024492a
Added issue number
Rik-de-Kort b424c8e
Updated to use .rows(sparse=False) for future compat
Rik-de-Kort 571489b
Merge branch 'master' of https://github.com/pandas-dev/pandas
Rik-de-Kort dad4a53
xfails in test_readers.py
Rik-de-Kort 9b6bc9a
xfail url loads
Rik-de-Kort File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,6 @@ dependencies: | |
- xlsxwriter | ||
- xlwt | ||
- pyarrow>=0.15 | ||
- pip | ||
- pip: | ||
- pyxlsb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,4 @@ dependencies: | |
- pip | ||
- pip: | ||
- pyreadstat | ||
- pyxlsb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,6 @@ dependencies: | |
- xlsxwriter | ||
- xlwt | ||
- pyreadstat | ||
- pip | ||
- pip: | ||
- pyxlsb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,3 +51,4 @@ dependencies: | |
- coverage | ||
- pandas-datareader | ||
- python-dateutil | ||
- pyxlsb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -19,6 +19,7 @@ | |||||
"pyarrow": "0.13.0", | ||||||
"pytables": "3.4.2", | ||||||
"pytest": "5.0.1", | ||||||
"pyxlsb": "1.0.5", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"s3fs": "0.3.0", | ||||||
"scipy": "0.19.0", | ||||||
"sqlalchemy": "1.1.4", | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from typing import List | ||
|
||
from pandas._typing import FilePathOrBuffer, Scalar | ||
from pandas.compat._optional import import_optional_dependency | ||
|
||
from pandas.io.excel._base import _BaseExcelReader | ||
|
||
|
||
class _PyxlsbReader(_BaseExcelReader): | ||
def __init__(self, filepath_or_buffer: FilePathOrBuffer): | ||
"""Reader using pyxlsb engine. | ||
|
||
Parameters | ||
__________ | ||
filepath_or_buffer: string, path object, or Workbook | ||
Object to be parsed. | ||
""" | ||
import_optional_dependency("pyxlsb") | ||
# This will call load_workbook on the filepath or buffer | ||
# And set the result to the book-attribute | ||
super().__init__(filepath_or_buffer) | ||
|
||
@property | ||
def _workbook_class(self): | ||
from pyxlsb import Workbook | ||
|
||
return Workbook | ||
|
||
def load_workbook(self, filepath_or_buffer: FilePathOrBuffer): | ||
from pyxlsb import open_workbook | ||
|
||
# Todo: hack in buffer capability | ||
# This might need some modifications to the Pyxlsb library | ||
# Actual work for opening it is in xlsbpackage.py, line 20-ish | ||
|
||
return open_workbook(filepath_or_buffer) | ||
|
||
@property | ||
def sheet_names(self) -> List[str]: | ||
return self.book.sheets | ||
|
||
def get_sheet_by_name(self, name: str): | ||
return self.book.get_sheet(name) | ||
|
||
def get_sheet_by_index(self, index: int): | ||
# pyxlsb sheets are indexed from 1 onwards | ||
# There's a fix for this in the source, but the pypi package doesn't have it | ||
return self.book.get_sheet(index + 1) | ||
|
||
def _convert_cell(self, cell, convert_float: bool) -> Scalar: | ||
# Todo: there is no way to distinguish between floats and datetimes in pyxlsb | ||
# This means that there is no way to read datetime types from an xlsb file yet | ||
if cell.v is None: | ||
return "" # Prevents non-named columns from not showing up as Unnamed: i | ||
if isinstance(cell.v, float) and convert_float: | ||
val = int(cell.v) | ||
if val == cell.v: | ||
return val | ||
else: | ||
return float(cell.v) | ||
|
||
return cell.v | ||
|
||
def get_sheet_data(self, sheet, convert_float: bool) -> List[List[Scalar]]: | ||
return [ | ||
[self._convert_cell(c, convert_float) for c in r] | ||
for r in sheet.rows(sparse=False) | ||
] |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.