[Numpy-discussion] Multiple string formatting while writing an array into a file

Gökhan Sever gokhansever@gmail....
Sun Oct 18 12:03:14 CDT 2009


Hello,

I have a relatively simple question which I couldn't figure out myself yet.
I have an array that I am writing into a file using the following savetxt
method.

np.savetxt(fid, output_array, fmt='%12.4f', delimiter='')


However, I have made some changes on the code and I require to write after
7th element of the array as integer instead of 12.4 formatted float. The
change below doesn't help me to solve the problem since I get a "ValueError:
setting an array element with a sequence."

np.savetxt(fid, (output_array[:7], output_array[7:]), fmt=('%12.4f',
'%12d'), delimiter='')

What would be the right approach to fix this issue?

Thanks.

-- 
Gökhan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20091018/50f6c0e2/attachment.html 


More information about the NumPy-Discussion mailing list