a sequence of formats in savetxt
![](https://secure.gravatar.com/avatar/612395b66b3e7959997007b342b3688a.jpg?s=120&d=mm&r=g)
Hi all, 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. Nils
![](https://secure.gravatar.com/avatar/f0e14e3d3fedba744ede17396d394c73.jpg?s=120&d=mm&r=g)
2008/11/18 Nils Wagner <nwagner@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
participants (2)
-
Nils Wagner
-
Scott Sinclair