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

Write out a dataset as an ASCII file.

  • 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 args if 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 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.


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

>>> write_data('src.dat', dat)