pydiodon.writefile¶
- pydiodon.writefile(A, filename, fmt=None, delimiter='\t', colnames=False, rownames=False, datasetname='values', np_fmt='%.18e', dtype='float32')[source]¶
A generic function for saving a numpy array as a file
- Parameters
- Aa numpy array
the array to be saved as a file
- filenamestring
the name of the file for saving the array (compulsory)
- fmtstring
explicit format of the file (compulsory) one item among
ascii
,hdf5
,zip
; see notes- delimitercharacter
the delimiter between values in a row
- colnamesboolean or string
column names
for an ascii file, it is boolean, with True if column names are as first row in the file, and False otherwise
for an hdf5 file, gives the name of the dataset with the column names
optionaldefault value is None.- rownamesboolean or string
row names
for an ascii file, it is boolean, as True is row names are as first column in the file, and False otherwise
for an hdf5 file, gives the name of the dataset with the row names
optionaldefault value is None.- datasetnamestring
- for writing files in hdf5 format only : hdf5 dataset for valuesoptionaldefault value is “value”
- fmtstring
is exactly the parameter
fmt
ofnumpy.savetxt()
for print format in ascii files to be done- dtypeto be done
- Returns
- writes a file
Notes
It writes the array in a file and returns no value. Parameters and choices are mirrored from function
loadfile()
as it is the reverse operation.Possible formats are:
ascii
,hdf5
andcompressed ascii
. Delimiters in ascii format can be blanks, comma, semi-columns, tabulations. Ascii data sets withtab
delimiters are expected to be with suffix.txt
. Ascii data sets with other delimiters are expected to be with siffix.csv
.jmf & af, 21.04.22, 22.10.28