[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:10:19 EST 2014


On Fri, Jan 17, 2014 at 1:44 PM, Oscar Benjamin
<oscar.j.benjamin at gmail.com>wrote:

> On Fri, Jan 17, 2014 at 10:59:27AM +0000, Pauli Virtanen wrote:
> > Julian Taylor <jtaylor.debian <at> googlemail.com> writes:
> > [clip]
>

> > > For backward compatibility we *cannot* change S.
>
> Do you mean to say that loadtxt cannot be changed from decoding using
> system
> default, splitting on newlines and whitespace and then encoding the
> substrings
> as latin-1?
>

unicode dtypes have nothing to do with the loadtxt issue. They are not
related.


>
> An obvious improvement would be along the lines of what Chris Barker
> suggested: decode as latin-1, do the processing and then reencode as
> latin-1.
>

no, the right solution is to add an encoding argument.
Its a 4 line patch for python2 and a 2 line patch for python3 and the issue
is solved, I'll file a PR later.

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140117/413a6d7f/attachment.html>


More information about the NumPy-Discussion mailing list