obspy.core.util.base.open_text_stream

open_text_stream(file_or_stream, encoding='utf-8')[source]

Context manager releasing a text data stream from the argument, e.g.: with open_text_stream(file_or_stream)

Parameters:
  • file_or_stream (str, Path or file-like object.) – The input object to open. If this parameter is already a file-like object, it will not be closed on exit but the stream position will be reset so that the object can be reused

  • encoding (str) – the encoding used. If the passed argument is already a file-like object of encoded text data, this argument is ignored

Returns:

a context manager to read text data