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 librariesexternal == 1
: (zcat, gzip, xz) or (bzcat, bzip2)external == 2
: (pigz -dc, pigz) or (pbzip2 -dc, pbzip2)- Parameters:
filename (
str
) – The filename to openmode (
str
, default:'r'
) – The mode with which to open the file handlebuff (
int
, default:1048576
) – Buffer sizeexternal (
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