actio_python_utils.utils.zopen

actio_python_utils.utils.zopen(filename, mode='r', buff=1048576, external=2)[source]

Open pipe, zipped, or unzipped file automagically

external == 0: normal zip libraries
external == 1: (zcat, gzip, xz) or (bzcat, bzip2)
external == 2: (pigz -dc, pigz) or (pbzip2 -dc, pbzip2)
Parameters:
  • filename (str) – The filename to open

  • mode (str, default: 'r') – The mode with which to open the file handle

  • buff (int, default: 1048576) – Buffer size

  • external (int, default: 2) – External process code usage

Raises:

ValueError – If “r” and “w” in mode or neither in mode

Return type:

TextIOWrapper

Returns:

The opened file handle