Skip to content

Commit d4e40c9

Browse files
Skn0ttMargarete01
andauthored
refactor: detect tar files using existing extension mapping
co-authored-by: Margarete Dippel <margarete01@users.noreply.github.com>
1 parent 6a8edef commit d4e40c9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pandas/io/common.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,16 @@ def file_path_to_url(path: str) -> str:
446446
return urljoin("file:", pathname2url(path))
447447

448448

449-
_extension_to_compression = {".gz": "gzip", ".bz2": "bz2", ".zip": "zip", ".xz": "xz"}
449+
_extension_to_compression = {
450+
".tar": "tar",
451+
".tar.gz": "tar",
452+
".tar.bz2": "tar",
453+
".tar.xz": "tar",
454+
".gz": "gzip",
455+
".bz2": "bz2",
456+
".zip": "zip",
457+
".xz": "xz",
458+
}
450459
_supported_compressions = set(_extension_to_compression.values())
451460

452461

@@ -522,9 +531,6 @@ def infer_compression(
522531
# Cannot infer compression of a buffer, assume no compression
523532
return None
524533

525-
if ".tar" in filepath_or_buffer:
526-
return "tar"
527-
528534
# Infer compression from the filename/URL extension
529535
for extension, compression in _extension_to_compression.items():
530536
if filepath_or_buffer.lower().endswith(extension):

0 commit comments

Comments
 (0)