Skip to content

Commit 54b8c4f

Browse files
authored
Removing explicit Excel engine configuration (#742)
* Removing explicit Excel engine configuration * [skip ci] - clarifying docs * Parallelizing test
1 parent b020915 commit 54b8c4f

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

awswrangler/s3/_read_excel.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ def read_excel(
2626
This function accepts any Pandas's read_excel() argument.
2727
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_excel.html
2828
29+
Note
30+
----
31+
Depending on the file extension ('xlsx', 'xls', 'odf'...), an additional library
32+
might have to be installed first (e.g. xlrd).
33+
2934
Note
3035
----
3136
In case of `use_threads=True` the number of threads
@@ -77,6 +82,5 @@ def read_excel(
7782
s3_additional_kwargs=s3_additional_kwargs,
7883
boto3_session=session,
7984
) as f:
80-
pandas_kwargs["engine"] = "openpyxl"
8185
_logger.debug("pandas_kwargs: %s", pandas_kwargs)
8286
return pd.read_excel(f, **pandas_kwargs)

awswrangler/s3/_write_excel.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def to_excel(
2727
This function accepts any Pandas's read_excel() argument.
2828
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_excel.html
2929
30+
Note
31+
----
32+
Depending on the file extension ('xlsx', 'xls', 'odf'...), an additional library
33+
might have to be installed first (e.g. xlrd).
34+
3035
Note
3136
----
3237
In case of `use_threads=True` the number of threads
@@ -83,7 +88,6 @@ def to_excel(
8388
s3_additional_kwargs=s3_additional_kwargs,
8489
boto3_session=session,
8590
) as f:
86-
pandas_kwargs["engine"] = "openpyxl"
8791
_logger.debug("pandas_kwargs: %s", pandas_kwargs)
8892
df.to_excel(f, **pandas_kwargs)
8993
return path

tests/test_s3_excel.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
logging.getLogger("awswrangler").setLevel(logging.DEBUG)
99

1010

11+
@pytest.mark.parametrize("ext", ["xlsx", "xlsm", "xls", "odf"])
1112
@pytest.mark.parametrize("use_threads", [True, False, 2])
12-
def test_excel(path, use_threads):
13-
file_path = f"{path}0.xlsx"
13+
def test_excel(path, ext, use_threads):
1414
df = pd.DataFrame({"c0": [1, 2, 3], "c1": ["foo", "boo", "bar"]})
15+
16+
file_path = f"{path}0.{ext}"
1517
wr.s3.to_excel(df, file_path, use_threads=use_threads, index=False)
1618
df2 = wr.s3.read_excel(file_path, use_threads=use_threads)
1719
assert df.equals(df2)

0 commit comments

Comments
 (0)