chisurf.fio.zipped module

chisurf.fio.zipped.open_maybe_zipped(filename: str, mode: str, force_overwrite: bool = True)[source]

Open a file in name (not binary) reading_routine, transparently handling .gz or .bz2 compression, with utf-8 encoding.

Parameters
  • filename (str) – Path to file. Compression will be automatically detected if the filename ends in .gz or .bz2.

  • mode ({'r', 'w'}) – Mode in which to open file

  • force_overwrite (bool, default=True) – If ‘w’, should we overwrite the file if something with filename already exists?

Returns

handle – Open file handle.

Return type

file