Skip to content

genfromtxt with names=True doesn't work with python3 #5411

@hsgg

Description

@hsgg

Using python 3.4.2 on Arch Linux with numpy 1.9.1, the following code doesn't work:

#!/usr/bin/env python

import sys
import numpy as np

data = np.genfromtxt(sys.stdin, names=True)

When running with a simple input file, it gives the following error:

Traceback (most recent call last):
  File "./test.py", line 6, in <module>
    data = np.genfromtxt(sys.stdin, names=True)
  File "/usr/lib/python3.4/site-packages/numpy/lib/npyio.py", line 1395, in genfromtxt
    if comments in first_line:
TypeError: 'in <string>' requires string as left operand, not bytes

The input file can be constructed with:

f = io.StringIO(u"""\
x y z
2.4 2.3 0.1
3.5 5.6 0.2""")

There is no problem with python2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions