[Numpy-discussion] array.tofile() refuses to write into a StringIO
Tue Sep 27 10:48:38 CDT 2011
On 9/27/11 2:14 AM, oc-spam66 wrote:
>> if you want to write to a string, why not use .tostring()?
> Because A.tostring() returns the binary data, while I would like the text representation.
> More precisely, I would like to use A.tofile(sep="\t").
I see -- I've always thought mingling binary and text reading and
writing was an API mistake.
> Ah, I found a workaround: savetxt() can work with a StringIO
> -> savetxt(file_buffer, A)
> This is only a workaround. I still think A.tofile() should be capable of
> writing into a StringIO.
or .tostring() should support text (but that's what savetxt is for)
Anyway, the text behavior of fromfile() and tofile() is broken in many
ways -- it really need a major refactor,and yes,this is one issue that
it would be nice to address. Or just get deprecate the text functionality.
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
More information about the NumPy-Discussion