[Numpy-discussion] using loadtxt to load a text file in to a numpy array

Julian Taylor jtaylor.debian at googlemail.com
Fri Jan 17 08:31:32 EST 2014


On Fri, Jan 17, 2014 at 2:10 PM, Julian Taylor <
jtaylor.debian at googlemail.com> wrote:

> On Fri, Jan 17, 2014 at 1:44 PM, Oscar Benjamin <
> oscar.j.benjamin at gmail.com> wrote:...
> ...
> No latin1 de/encoding is required for anything, I don't know why you would
> want do to that in this context.
> Does opening latin1 files even work with current loadtxt?
> It currently uses UTF-8 which is to my knowledge not compatible with
> latin1.
>

just tried it, doesn't work so there is nothing we need to keep working:

f = codecs.open('test.txt', 'wt', encoding='latin1')
f.write(u'Öö\n')
f.close()
np.loadtxt('test.txt')

ValueError: could not convert string to float: ��
or UnicodeDecodeError: if provided with unicode dtype

there are a couple more unicode issues in the test loading (it converts to
bytes even if unicode is requested), but they look simple to fix.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140117/2692c62c/attachment.html>


More information about the NumPy-Discussion mailing list