write_arrays¶
- 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.
- Parameters
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
argsif 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 whenfieldsis not None.clobber (bool, optional) – If
filenameis notNone, 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%'.
- Raises
sherpa.utils.err.IOErr – If
filenamealready exists andclobberisFalseor if there is no data to write.
See also
Examples
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"], clobber=True)