savetxt

mdtools.file_handler.savetxt(fname, data, fmt='%16.9e', delimiter=' ', newline='\n', header='', footer='', comments='# ', encoding=None, rename=True)[source]

Save an array to a text file.

Parameters
  • fname (str) – The name of the file to create.

  • data (array_like) – 1- or 2-dimensional array of data to be saved.

  • fmt (str or sequence of strs, optional) – Format specifier. See numpy.savetxt() for more details.

  • delimiter (str, optional) – String or character separating columns.

  • newline (str, optional) – String or character separating lines.

  • header (str, optional) – String that will be written at the beginning of the file, additional to the standard MDTools header. See mdtools.file_handler.header_str() for more details.

  • footer (str, optional) – String that will be written at the end of the file.

  • comments (str, optional) – String that will be prepended to the header and footer strings, to mark them as comments.

  • encoding ({None, str}, optional) – Encoding used to encode the outputfile. Does not apply to output streams. See documentation of numpy.savetxt().

  • rename (bool, optional) – If True and a file called fname already exists, rename it to 'fname.bak_timestamp'. See mdtools.file_handler.backup() for more details.

See also

numpy.savetxt()

Save an array to a text file

mdtools.file_handler.savetxt_matrix()

Save a data matrix to a text file

mdtools.file_handler.header_str()

Create a standard header string for text files

mdtools.file_handler.backup()

Backup a file by renaming it

Notes

This function simply calls numpy.savetxt() and adds a MDTools specific header to the output file. See mdtools.file_handler.header_str() for further information about what is included in the header.