Motivation
Hello, I've been away from the project for a long time, and could not find discussions over some features of savetxt that I find useful, following mostly numpy savetxt behavior. I'd like to change the interface to something like. Please let me know
if there is any interest. As I said I could not find if it already was discussed and discarded.
I am proposing to add several arguments.
- Adding the possibility of providing a
unit number in place of a filename gives flexibility to add partial tables to a file.
fmt Gives the possibility of customize the output. In many cases complex calculations give only a few significant figures and I would like the number saved to express that. Should work in a similar way as it does in loadtxt().
header and footer give the possibility to add information to the data files (column names, information on parameters used in calculations or measurements, etc). I find this very important because it allows to keep information together with data.
- Following numpy I find extremely useful if non-data information is commented or signaled in some form. This would be the use of the argument
comments.
- I would propose to change the length of delimiter from len=1 to arbitrary length. For intstance, we may want a *.cvs file to be separated by a comma and one or more spaces ', '.
The spec would be something like:
savetxt - save a 2D array into a text file
Status
Experimental
Description
Saves a rank-2 array into a text file.
Syntax
call [[stdlib_io(module):savetxt(interface)]] (array [, filename | unit] [, delimiter] [, fmt] [, header] [, footer] [, comments])
Arguments
array: Shall be a rank-2 array of type real, complex or integer.
filename (optional): Shall be a character expression containing the name of the file , that will contain the 2D array. Present at the same time than unit will give an error.
unit (optional): Shall be an integer containing the unit of an already opened file. Present at the same time than filename will give an error.
delimiter (optional): Shall be a character expression of any length that contains the delimiter used to separate the columns. The default is a single space ' '.
fmt (optional): Fortran format specifier for the text save. Defaults to the write format for the data type.
header (optional): Shall be a character expression that will be written at the beginning of the file.
footer (optional): Shall be a character expression that will be written at the end of the file.
comments (optional): Shall be a character expression of (length 1 that will be prepended to the header and footer strings to mark them as comments. Default: # .
Prior Art
Additional Information
No response
Motivation
Hello, I've been away from the project for a long time, and could not find discussions over some features of savetxt that I find useful, following mostly numpy savetxt behavior. I'd like to change the interface to something like. Please let me know
if there is any interest. As I said I could not find if it already was discussed and discarded.
I am proposing to add several arguments.
unitnumber in place of a filename gives flexibility to add partial tables to a file.fmtGives the possibility of customize the output. In many cases complex calculations give only a few significant figures and I would like the number saved to express that. Should work in a similar way as it does inloadtxt().headerandfootergive the possibility to add information to the data files (column names, information on parameters used in calculations or measurements, etc). I find this very important because it allows to keep information together with data.comments.The spec would be something like:
savetxt- save a 2D array into a text fileStatus
Experimental
Description
Saves a rank-2
arrayinto a text file.Syntax
call[[stdlib_io(module):savetxt(interface)]](array [, filename | unit] [, delimiter] [, fmt] [, header] [, footer] [, comments])Arguments
array: Shall be a rank-2 array of typereal,complexorinteger.filename(optional): Shall be a character expression containing the name of the file , that will contain the 2Darray. Present at the same time thanunitwill give an error.unit(optional): Shall be an integer containing the unit of an already opened file. Present at the same time thanfilenamewill give an error.delimiter(optional): Shall be a character expression of any length that contains the delimiter used to separate the columns. The default is a single space' '.fmt(optional): Fortran format specifier for the text save. Defaults to the write format for the data type.header(optional): Shall be a character expression that will be written at the beginning of the file.footer(optional): Shall be a character expression that will be written at the end of the file.comments(optional): Shall be a character expression of (length 1 that will be prepended to theheaderandfooterstrings to mark them as comments. Default:#.Prior Art
Python Numpy savetxt
I've written a similar function in numfor
Additional Information
No response