sherpa.io.write_arrays(filename, args, fields=None, sep=' ', comment='#', clobber=False, linebreak='\n', format='%g')[source] [edit on github]

Write a list of arrays to an ASCII file.

  • filename (str) – The name of the file to write the array to.

  • args (array_like) – The arrays to write out.

  • fields (array_like of str) – The column names (should match the size of args if given).

  • sep (str, optional) – The separator character. The default is ' '.

  • comment (str, optional) – The comment character. The default is '#'. This is only used to write out the column names when fields is not None.

  • clobber (bool, optional) – If filename is not None, then this flag controls whether an existing file can be overwritten (True) or if it raises an exception (False, the default setting).

  • linebreak (str, optional) – Indicate a new line. The default is '\n'.

  • format (str, optional) – The format used to write out the numeric values. The default is '%g%'.


sherpa.utils.err.IOErr – If filename already exists and clobber is False or if there is no data to write.

See also



Write the x and y arrays to the file ‘src.dat’:

>>> write_arrays('src.dat', [x, y])

Use the column names “r” and “surbri” for the columns:

>>> write_arrays('prof.txt', [x, y], fields=["r", "surbri"],