pynxxas.io.utils.read_textfile#

pynxxas.io.utils.read_textfile(filename, size=None)[source]#

read text from a file as string

filename (str or file): name of file to read or file-like object size (int or None): number of bytes to read

text of file as string.

  1. the encoding is detected with charset_normalizer.from_bytes which is then used to decode bytes read from file.

  2. line endings are normalized to be ‘

‘, so that

splitting on ‘

‘ will give a list of lines.
  1. if filename is given, it can be a gzip-compressed file