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

feat: deprecated Table.from_excel_file and Table.to_excel_file #728

Merged
merged 1 commit into from
May 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/safeds/data/tabular/containers/_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ def from_excel_file(path: str | Path) -> Table:

Valid file extensions are `.xls`, '.xlsx', `.xlsm`, `.xlsb`, `.odf`, `.ods` and `.odt`.

!!! warning "Deprecated"
Convert your data to a CSV file and use
[Table.from_csv_file][safeds.data.tabular.containers._table.Table.from_csv_file] instead.

Parameters
----------
path:
Expand All @@ -150,6 +154,13 @@ def from_excel_file(path: str | Path) -> Table:
1 2 5
2 3 6
"""
warnings.warn(
"This method is deprecated and will be removed in a future version. "
"Convert your data to a CSV file and use `Table.from_csv_file` instead.",
DeprecationWarning,
stacklevel=2,
)

import pandas as pd

path = Path(path)
Expand Down Expand Up @@ -2357,6 +2368,9 @@ def to_excel_file(self, path: str | Path) -> None:
If the file and/or the directories do not exist, they will be created. If the file already exists, it will be
overwritten.

!!! warning "Deprecated"
Use [`to_csv_file`][safeds.data.tabular.containers._table.Table.to_csv_file] instead.

Parameters
----------
path:
Expand All @@ -2373,6 +2387,12 @@ def to_excel_file(self, path: str | Path) -> None:
>>> table = Table.from_dict({"a": [1, 2, 3], "b": [4, 5, 6]})
>>> table.to_excel_file("./src/resources/to_excel_file.xlsx")
"""
warnings.warn(
"This method is deprecated and will be removed in a future version. Use `Table.to_csv_file` instead.",
DeprecationWarning,
stacklevel=2,
)

import openpyxl

path = Path(path)
Expand Down