write_data
- sherpa.io.write_data(filename: str, dataset: Data, fields: Sequence[str] | None = None, sep: str = ' ', comment: str = '#', clobber: bool = False, linebreak: str = '\n', format: str = '%g') None[source] [edit on github]
Write out a dataset as an ASCII file.
- Parameters:
filename (str) – The name of the file to write the array to.
dataset – The data object to write out.
fields (array_like of str) – The column names (should match the size of
argsif given). Any unknown columns are skipped. If not given then the field names from the data set will be used (for those columns which contain data).sep (str, optional) – The separator character. The default is
' '.comment (str, optional) – The comment character. The default is
'#'. This is used to write out the column names (after converting to upper case) before the data.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_data('src.dat', dat)