From ff9fc5bd69d2766c6b592585b5b9eb422950f3cd Mon Sep 17 00:00:00 2001 From: willbowditch <14288042+willbowditch@users.noreply.github.com> Date: Tue, 7 Jul 2020 18:16:07 +0100 Subject: [PATCH 1/4] Infer compression even if file extension is uppercase --- pandas/io/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/io/common.py b/pandas/io/common.py index 51323c5ff3ef5..4e6395fc67b2a 100644 --- a/pandas/io/common.py +++ b/pandas/io/common.py @@ -311,7 +311,7 @@ def infer_compression( # Infer compression from the filename/URL extension for compression, extension in _compression_to_extension.items(): - if filepath_or_buffer.endswith(extension): + if filepath_or_buffer.lower().endswith(extension): return compression return None From 6f75ac5dab51c7505455acbafa232c4ee387c5c4 Mon Sep 17 00:00:00 2001 From: willbowditch <14288042+willbowditch@users.noreply.github.com> Date: Tue, 7 Jul 2020 18:28:19 +0100 Subject: [PATCH 2/4] Add upercase extensions to infer compression tests --- pandas/tests/io/test_common.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index e2f4ae04c1f9f..dde38eb55ea7f 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -87,7 +87,17 @@ def test_stringify_path_fspath(self): @pytest.mark.parametrize( "extension,expected", - [("", None), (".gz", "gzip"), (".bz2", "bz2"), (".zip", "zip"), (".xz", "xz")], + [ + ("", None), + (".gz", "gzip"), + (".bz2", "bz2"), + (".zip", "zip"), + (".xz", "xz"), + (".GZ", "gzip"), + (".BZ2", "bz2"), + (".ZIP", "zip"), + (".XZ", "xz"), + ], ) @pytest.mark.parametrize("path_type", path_types) def test_infer_compression_from_path(self, extension, expected, path_type): From 6e2cd6d4809d3569e03897b36f741c723d43f67f Mon Sep 17 00:00:00 2001 From: willbowditch <14288042+willbowditch@users.noreply.github.com> Date: Tue, 7 Jul 2020 18:40:34 +0100 Subject: [PATCH 3/4] Update whatsnew --- doc/source/whatsnew/v1.1.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.1.0.rst b/doc/source/whatsnew/v1.1.0.rst index cee41f248fc60..9cbc5bd6325ed 100644 --- a/doc/source/whatsnew/v1.1.0.rst +++ b/doc/source/whatsnew/v1.1.0.rst @@ -1050,6 +1050,7 @@ I/O - Bug in :meth:`~HDFStore.create_table` now raises an error when `column` argument was not specified in `data_columns` on input (:issue:`28156`) - :meth:`read_json` now could read line-delimited json file from a file url while `lines` and `chunksize` are set. - Bug in :meth:`DataFrame.to_sql` when reading DataFrames with ``-np.inf`` entries with MySQL now has a more explicit ``ValueError`` (:issue:`34431`) +- Bug in :meth:`io.common.infer_compression` where capitalised files extensions were not decompressed by read_* functions. Plotting ^^^^^^^^ From a3558fd33ac0aa34e964b9a048d23f814778b98a Mon Sep 17 00:00:00 2001 From: willbowditch <14288042+willbowditch@users.noreply.github.com> Date: Fri, 10 Jul 2020 18:37:06 +0100 Subject: [PATCH 4/4] Add PR number --- doc/source/whatsnew/v1.1.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.1.0.rst b/doc/source/whatsnew/v1.1.0.rst index 9cbc5bd6325ed..8f07951de4256 100644 --- a/doc/source/whatsnew/v1.1.0.rst +++ b/doc/source/whatsnew/v1.1.0.rst @@ -1050,7 +1050,7 @@ I/O - Bug in :meth:`~HDFStore.create_table` now raises an error when `column` argument was not specified in `data_columns` on input (:issue:`28156`) - :meth:`read_json` now could read line-delimited json file from a file url while `lines` and `chunksize` are set. - Bug in :meth:`DataFrame.to_sql` when reading DataFrames with ``-np.inf`` entries with MySQL now has a more explicit ``ValueError`` (:issue:`34431`) -- Bug in :meth:`io.common.infer_compression` where capitalised files extensions were not decompressed by read_* functions. +- Bug where capitalised files extensions were not decompressed by read_* functions (:issue:`35164`) Plotting ^^^^^^^^