8000 recfromtext bytes delimiter · Issue #11028 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
recfromtext bytes delimiter #11028
Closed
Closed
@barronh

Description

@barronh

I had existing code that uses BytesIO and a byte delimiter. It worked in <=1.13 and breaks after. The code works if the delimiter is switched to a string. All tests were performed with Python 3.6.5 from Anaconda. The failure can be reproduced using the excerpt below.

Fails using 1.14.0, 1.14.1, and 1.14.2

python -c "import numpy as np; import io; print(np.version.version); data = np.recfromtxt(io.BytesIO(b'SPC:MW\nNO:30\nNO2:36'), delimiter=b':', dtype = ['S3', 'f4']); print(data)"
1.14.2
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/work/ROMO/anaconda3/envs/testnp113/lib/python3.6/site-packages/numpy/lib/npyio.py", line 2230, in recfromtxt
    output = genfromtxt(fname, **kwargs)
  File "/work/ROMO/anaconda3/envs/testnp113/lib/python3.6/site-packages/numpy/lib/npyio.py", line 2116, in genfromtxt
    rows = np.array(data, dtype=[('', _) for _ in dtype_flat])
ValueError: could not assign tuple of length 1 to structure with 2 fields.

Passes with 1.13.3

python -c "import numpy as np; import io; print(np.version.version); data = np.recfromtxt(io.BytesIO(b'SPC:MW\nNO:30\nNO2:36'), delimiter=b':', dtype = ['S3', 'f4']); print(data)"
1.13.3
[(b'SPC',  nan) (b'NO',  30.) (b'NO2',  36.)]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0