-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DEPR: xlwt for writing excel files #38317
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
Changes from 1 commit
8c748b4
15ca786
e0de115
595de4c
f7321d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -587,6 +587,13 @@ class ExcelWriter(metaclass=abc.ABCMeta): | |
Engine to use for writing. If None, defaults to | ||
``io.excel.<extension>.writer``. NOTE: can only be passed as a keyword | ||
argument. | ||
|
||
.. deprecated:: 1.2.0 | ||
|
||
The `xlwt <https://pypi.org/project/xlwt/>`__ engine, the only engine | ||
that supports writing in an xls format, is no longer maintained and | ||
will be removed in a future version of pandas. | ||
|
||
date_format : str, default None | ||
Format string for dates written into Excel files (e.g. 'YYYY-MM-DD'). | ||
datetime_format : str, default None | ||
|
@@ -691,11 +698,28 @@ def __new__(cls, path, engine=None, **kwargs): | |
ext = "xlsx" | ||
|
||
try: | ||
engine = config.get_option(f"io.excel.{ext}.writer") | ||
engine = config.get_option(f"io.excel.{ext}.writer", silent=True) | ||
if engine == "auto": | ||
engine = get_default_writer(ext) | ||
except KeyError as err: | ||
raise ValueError(f"No engine for filetype: '{ext}'") from err | ||
|
||
if engine == "xlwt": | ||
xls_config_engine = config.get_option( | ||
"io.excel.xls.writer", silent=True | ||
) | ||
# Don't warn a 2nd time if user has changed the default engine for xls | ||
if xls_config_engine != "xlwt": | ||
warnings.warn( | ||
"The xlwt engine, the only engine that supports writing in " | ||
"an xls format, is no longer maintained and will be removed in " | ||
"a future version of pandas. Install openpyxl and write to an " | ||
"xlsx file instead. You can set the option " | ||
"io.excel.xls.writer to 'xlwt' to silence this warning.", | ||
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. But setting the option is also deprecated and will also raise a warning? 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. Yes - but at least it is in hopefully fewer places in user code. The warning can still be ignored there, but I see now that will cause confusion when a user follows the instruction and then still gets a warning. I'm thinking I'll change to:
|
||
FutureWarning, | ||
stacklevel=4, | ||
) | ||
|
||
cls = get_writer(engine) | ||
|
||
return object.__new__(cls) | ||
|
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.
Nitpick: it's the package that is no longer maintained, and the engine that will be removed (now it reads like the code in pandas that will be removed is no longer maintained)
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.
(now, since it's written this way in many places in your PR (and the previous one), it might not be worth it to change ..)
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 appreciate the nitpicks; and as long as it's not holding things up happy to work on it to get it right. What do you think of: