PyDocs

Nav

Data Compression and Archiving

open

  • open(file, /, mode='rb', *, level=None, options=None, zstd_dict=None, encoding=None, errors=None, newline=None)
Open a Zstandard compressed file in binary or text mode.

file can be either a file name (given as a str, bytes, or PathLike
object), in which case the named file is opened, or it can be
an existing file object to read from or write to.

The mode parameter can be 'r', 'rb' (default), 'w', 'wb', 'x', 'xb',
'a', 'ab' for binary mode, or 'rt', 'wt', 'xt', 'at' for text mode.

The level, options, and zstd_dict parameters specify the settings the
same as ZstdFile.

When using read mode (decompression), the options parameter is a dict
representing advanced decompression options.  The level parameter is not
supported in this case.  When using write mode (compression), only one
of level, an int representing the compression level, or options, a dict
representing advanced compression options, may be passed.  In both
modes, zstd_dict is a ZstdDict instance containing a trained Zstandard
dictionary.

For binary mode, this function is equivalent to the ZstdFile
constructor: ZstdFile(filename, mode, ...).  In this case, the encoding,
errors and newline parameters must not be provided.

For text mode, an ZstdFile object is created, and wrapped in an
io.TextIOWrapper instance with the specified encoding, error handling
behavior, and line ending(s).
0 Examples
No examples for compression.zstd/open.
See Also
No see-alsos for compression.zstd/open
0 Notes
No notes for open