numpy.genfromtxt with Python3 - howto
Marc Christiansen
usenet at solar-empire.de
Fri Apr 6 18:03:21 EDT 2012
Helmut Jarausch <jarausch at skynet.be> wrote:
> I have a machine with a non-UTF8 local.
> I can't figure out how to make numpy.genfromtxt work
[...]
> #!/usr/bin/python3
> import numpy as np
> import io
> import sys
>
> inpstream = io.open(sys.stdin.fileno(), "r", encoding='latin1')
>
> data = np.genfromtxt(inpstream)
Hi Helmut, numpy.genfromtxt wants bytes, not str. Use
inpstream = io.open(sys.stdin.fileno(), "rb")
or simply
inpstream = sys.stdin.buffer
Ciao
Marc
More information about the Python-list
mailing list