Skip to content

seems that from 1.23 the 'delimiter' option of loadtxt require single unicode character #22311

@dlanguig3

Description

@dlanguig3

Describe the issue:

It seems that starting from 1.23 the 'delimiter' option of loadtxt requires a single unicode character where a random string was allowed before (and the doc of 1.23 doesn't tell about this new behavior)

So, when running code that worked fine up before 1.23, we get the error whose stack trace is below.

Reproduce the code example:

import numpy as np

np.loadtxt(pos_file,comments="@",delimiter="val=",usecols=(0,))

where the text file is something like:
------
field1val=12val=13val=14
field2val=22val=23val=24
------

Error message:

Traceback (most recent call last):
 File "", line 114, in <module>
   pos_data = np.loadtxt(pos_file,comments="@",delimiter="val=",usecols=(0,))
 File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy/lib/npyio.py", line 1313, in loadtxt
   arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter,
 File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy/lib/npyio.py", line 979, in _read
   arr = _load_from_filelike(
TypeError: Text reading control character must be a single unicode character or None; but got: 'val='

NumPy/Python version information:

1.23.0

Context for the issue:

j

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions