BUG: np.loadtxt cannot load text file with quoted fields separated by whitespace#22906
BUG: np.loadtxt cannot load text file with quoted fields separated by whitespace#22906seberg merged 4 commits intonumpy:mainfrom
Conversation
dmbelov
commented
Dec 30, 2022
- Resolves issue BUG: np.loadtxt cannot load text file with quoted fields separated by whitespace #22899
- Fixed a bug in parsing line containing quoted fields separated by white spaces
- Added doctest
…tespace. Added doctest.
| 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') |
There was a problem hiding this comment.
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:
| >>> s = StringIO('"alpha, #42" 10.0\n"beta, #64" 2.0\n') | |
| >>> s = StringIO('"alpha, #42" 10.0\n"beta, #64" 2.0\n') |
|
Thanks @seberg. I committed the change that you suggested. |
|
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. EDIT: Oh, Chuck already marked it, oops. |
|
Thank you for so quickly merging it into main branch. |
|
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 |
… whitespace (numpy#22906) Fix issue with `delimiter=None` and quote character not working properly (not using whitespace delimiter mode). Closes numpygh-22899