Skip to content

BUG: np.loadtxt cannot load text file with quoted fields separated by whitespace#22906

Merged
seberg merged 4 commits intonumpy:mainfrom
dmbelov:loadtxt-bugfix
Jan 1, 2023
Merged

BUG: np.loadtxt cannot load text file with quoted fields separated by whitespace#22906
seberg merged 4 commits intonumpy:mainfrom
dmbelov:loadtxt-bugfix

Conversation

@dmbelov
Copy link
Copy Markdown
Contributor

@dmbelov dmbelov commented Dec 30, 2022

dtype=[('label', '<U12'), ('value', '<f8')])

Quoted fields can be separated by multiple whitespace characters
>>> s = StringIO('"alpha, #42" 10.0\n"beta, #64" 2.0\n')
Copy link
Copy Markdown
Member

@seberg seberg Dec 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this, this looks good to me and like a clear bugfix. I am still travelling and not really around, so sorry for the small delay.

The one thing is that the circleCI runs are failing with:

/home/circleci/repo/venv/lib/python3.8/site-packages/numpy/__init__.py:docstring of numpy.loadtxt:253: ERROR: Unexpected indentation.

I suspect this should fix it though:

Suggested change
>>> s = StringIO('"alpha, #42" 10.0\n"beta, #64" 2.0\n')
>>> s = StringIO('"alpha, #42" 10.0\n"beta, #64" 2.0\n')

@charris charris changed the title Resolves issue #22899: np.loadtxt cannot load text file with quoted fields separated by whitespace BUG: np.loadtxt cannot load text file with quoted fields separated by whitespace Dec 31, 2022
@charris charris added 00 - Bug 09 - Backport-Candidate PRs tagged should be backported labels Dec 31, 2022
@charris charris added this to the 1.24.2 release milestone Dec 31, 2022
@dmbelov
Copy link
Copy Markdown
Contributor Author

dmbelov commented Jan 1, 2023

Thanks @seberg. I committed the change that you suggested.

@seberg
Copy link
Copy Markdown
Member

seberg commented Jan 1, 2023

Marking for backport, since I agree it is a clear bug-fix. Going to merge once CI passes, thanks. I don't know if we need the example, but there is so much example that I think it doesn't hurt.
Thanks for making the PR, @dmbelov!

EDIT: Oh, Chuck already marked it, oops.

@seberg seberg merged commit 6d474f2 into numpy:main Jan 1, 2023
@dmbelov
Copy link
Copy Markdown
Contributor Author

dmbelov commented Jan 1, 2023

Thank you for so quickly merging it into main branch.

@InessaPawson
Copy link
Copy Markdown
Member

Hi-five on merging your first pull request to NumPy, @dmbelov! We hope you stick around! Your choices aren’t limited to writing code – you can review pull requests, help us stay on top of new and old issues, develop educational material, work on our website, add or improve graphic design, create marketing materials, translate website content, write grant proposals, and help with other fundraising initiatives. For more info, check out: https://numpy.org/contribute
Also, consider joining our mailing list. This is a great way to connect with other cool people in our community and be part of important conversations that affect the development of NumPy: https://mail.python.org/mailman/listinfo/numpy-discussion

charris pushed a commit to charris/numpy that referenced this pull request Jan 8, 2023
… whitespace (numpy#22906)

Fix issue with `delimiter=None` and quote character not working properly (not using whitespace delimiter mode).

Closes numpygh-22899
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jan 8, 2023
@charris charris removed this from the 1.24.2 release milestone Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Second contribution

Development

Successfully merging this pull request may close these issues.

4 participants