MCPcopy
hub / github.com/pandas-dev/pandas / decompress_file

Function decompress_file

pandas/_testing/contexts.py:27–46  ·  view source on GitHub ↗

Open a compressed file and return a file object. Parameters ---------- path : str The path where the file is read from. compression : {'gzip', 'bz2', 'zip', 'xz', 'zstd', None} Name of the decompression to use Returns ------- file object

(
    path: FilePath | BaseBuffer, compression: CompressionOptions
)

Source from the content-addressed store, hash-verified

25
26@contextmanager
27def decompress_file(
28 path: FilePath | BaseBuffer, compression: CompressionOptions
29) -> Generator[IO[bytes]]:
30 """
31 Open a compressed file and return a file object.
32
33 Parameters
34 ----------
35 path : str
36 The path where the file is read from.
37
38 compression : {'gzip', 'bz2', 'zip', 'xz', 'zstd', None}
39 Name of the decompression to use
40
41 Returns
42 -------
43 file object
44 """
45 with get_handle(path, "rb", compression=compression, is_text=False) as handle:
46 yield handle.handle
47
48
49@contextmanager

Callers

nothing calls this directly

Calls 1

get_handleFunction · 0.90

Tested by

no test coverage detected