Save an array to a text file.
Parameters : | fname : filename or file handle
X : array_like
fmt : str or sequence of strs
delimiter : str
newline : str
|
---|
See also
Notes
Further explanation of the fmt parameter (%[flag]width[.precision]specifier):
- : left justify
+ : Forces to preceed result with + or -.
0 : Left pad the number with zeros instead of space (see width).
c : character
d or i : signed decimal integer
e or E : scientific notation with e or E.
f : decimal floating point
g,G : use the shorter of e,E or f
o : signed octal
s : string of characters
u : unsigned decimal integer
x,X : unsigned hexadecimal integer
This explanation of fmt is not complete, for an exhaustive specification see [R218].
References
[R218] | (1, 2) Format Specification Mini-Language, Python Documentation. |
Examples
>>> x = y = z = np.arange(0.0,5.0,1.0)
>>> np.savetxt('test.out', x, delimiter=',') # X is an array
>>> np.savetxt('test.out', (x,y,z)) # x,y,z equal sized 1D arrays
>>> np.savetxt('test.out', x, fmt='%1.4e') # use exponential notation