[SciPy-user] Multicolumn file io

Nathan Bell wnbell at gmail.com
Sat Feb 14 20:06:34 EST 2009


On Sat, Feb 14, 2009 at 4:44 PM, Stéfan van der Walt <stefan at sun.ac.za> wrote:
>
> np.savetxt('/tmp/data.txt', np.array([x, y]).T)
>
> or
>
> np.savetxt('/tmp/data.txt', np.array([x, y]).T, fmt='%.0f')
>

To that I'd add that if some columns are integers and others are
floats that fmt='%g' gives you the desired (compact) output even
though the combined array has a floating point type.

-- 
Nathan Bell wnbell at gmail.com
http://graphics.cs.uiuc.edu/~wnbell/



More information about the SciPy-User mailing list