[SciPy-user] a sequence of formats in savetxt

Scott Sinclair scott.sinclair.za at gmail.com
Tue Nov 18 08:33:35 EST 2008


2008/11/18 Nils Wagner <nwagner at iam.uni-stuttgart.de>:
> How do I specify a sequence of formats in savetxt ?
>
> savetxt('f06.dat',F,fmt='%10.5f %i4 4%10.5f') doesn't work
>
> F is an (m,5) array.
> The entries of the second column should be stored as
> integers.

Your format string will need 5 different format specifiers if F has 5 columns.

>>> savetxt('f06.dat', F, fmt='%10.5f %4d %10.5f %10.5f %10.5f')

The above should work with your (m, 5) array, giving you an integer in
the second column of each line in the file, with all other columns
being floating point.

The documentation for savetxt is at
http://docs.scipy.org/doc/numpy/reference/generated/numpy.savetxt.html

Cheers,
Scott



More information about the SciPy-User mailing list