[Numpy-discussion] how do I specify maximum line length when using savetxt?

Mark Bakker markbak@gmail....
Wed Dec 5 17:40:17 CST 2012

I guess I wasn't explicit enough.
Say I have an array with 100 numbers and I want to write it to a file
with 6 numbers on each line (and hence, only 4 on the last line).
Can I use savetxt to do that?
What other easy tool does numpy have to do that?

On 5. des. 2012, at 22:35, Mark Bakker wrote:

> Hello List,
> I want to write a large array to file, and each line can only be 80
> characters long.
> Can I use savetxt to do that? Where would I specify the maximum line length?

If you specify the format, %10.3f for instance, you will know the max
line length if you also know the array shape.

> Or is there a better way to do this?

Probably 1000 ways to accomplish the same thing out there, sure.


More information about the NumPy-Discussion mailing list