pandas 1.4.2

Parameters
get_handle(path_or_buf: 'FilePath | BaseBuffer', mode: 'str', *, encoding: 'str | None' = None, compression: 'CompressionOptions' = None, memory_map: 'bool' = False, is_text: 'bool' = True, errors: 'str | None' = None, storage_options: 'StorageOptions' = None) -> 'IOHandles[str] | IOHandles[bytes]'

Parameters

path_or_buf : str or file handle

File path or object.

mode : str

Mode to open path_or_buf with.

encoding : str or None

Encoding to use.

compression : str or dict, default 'infer'

For on-the-fly compression of the output data. If 'infer' and 'path_or_buf' path-like, then detect compression from the following extensions: '.gz', '.bz2', '.zip', '.xz', or '.zst' (otherwise no compression). Set to None for no compression. Can also be a dict with key 'method' set to one of { 'zip' , 'gzip' , 'bz2' , 'zstd' } and other key-value pairs are forwarded to zipfile.ZipFile , gzip.GzipFile , bz2.BZ2File , or zstandard.ZstdDecompressor , respectively. As an example, the following could be passed for faster compression and to create a reproducible gzip archive: compression={'method': 'gzip', 'compresslevel': 1, 'mtime': 1} .

versionchanged

May now be a dict with key 'method' as compression mode and other keys as compression options if compression mode is 'zip'.

versionchanged

Passing compression options as keys in dict is now supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'.

versionchanged
memory_map : bool, default False

See parsers._parser_params for more information.

is_text : bool, default True

Whether the type of the content passed to the file/buffer is string or bytes. This is not the same as :None:None:`"b" not in mode`. If a string content is passed to a binary file/buffer, a wrapper is inserted.

errors : str, default 'strict'

Specifies how encoding and decoding errors are to be handled. See the errors argument for open for a full list of options.

storage_options: StorageOptions = None :

Passed to _get_filepath_or_buffer

.. versionchanged:: 1.2.0 :
Returns the dataclass IOHandles :

Get file handle for given path/buffer and mode.

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/io/common.py#604
type: <class 'function'>
Commit: