-
Notifications
You must be signed in to change notification settings - Fork 119
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
#450: Polars spreadsheet IO along with example and test case. #471
Conversation
from polars.selectors import _selector_proxy_ | ||
from polars.datatypes import DataType, DataTypeClass |
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.
@skrawcz Any better way to do this? This is unused import, not adding this import causing issue in materialization step for not finding this classes.
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.
actually I don't understand, why are they required if they're not referenced below?
|
||
def save_data(self, data: DATAFRAME_TYPE) -> Dict[str, Any]: | ||
data.write_excel(self.workbook, **self._get_saving_kwargs()) | ||
return utils.get_file_metadata(self.workbook) |
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.
this might not work if it's a workbook object. So probably want to check the type here/pull out some information if possible.
@@ -77,6 +79,24 @@ def test_polars_feather(tmp_path: pathlib.Path) -> None: | |||
assert metadata["path"] == file_path | |||
|
|||
|
|||
def test_polars_spreadsheet(df: pl.DataFrame, tmp_path: pathlib.Path) -> None: | |||
file = tmp_path / "test.excel" |
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.
this will break.
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.
Why do this this will break?
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.
🤔 I don't recall. 😅 But I think I might have been referring to how the code looked previously? Otherwise from reading things, you can pass a path and it'll save to it -- so this won't break as far as I can tell without running the code :)
@swapdewalkar how are things going? Do you need any help? |
@skrawcz I will try to finish this week? |
@swapdewalkar how are things going? Do you need any help? |
Should map to https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.DataFrame.write_excel.html | ||
""" | ||
|
||
workbook: Union[Workbook, BytesIO, str, Path] = None |
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.
I think we shouldn't allow this to be None.
I don't think the default that polars has makes sense here. So I think we want someone to always input something here to direct where to save it.
kwargs1 = writer._get_saving_kwargs() | ||
writer.save_data(df) |
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.
you should save the response from save_data()
and validate that.
PR address #450
Changes
Polars spreadsheet IO along with example and test case.
How I tested this
Notes
Checklist