diff --git a/numpy/core/src/multiarray/textreading/tokenize.cpp b/numpy/core/src/multiarray/textreading/tokenize.cpp index 9cb32634d825..5a85fd402dd4 100644 --- a/numpy/core/src/multiarray/textreading/tokenize.cpp +++ b/numpy/core/src/multiarray/textreading/tokenize.cpp @@ -223,7 +223,8 @@ tokenizer_core(tokenizer_state *ts, parser_config *const config) } else { /* continue parsing as if unquoted */ - ts->state = TOKENIZE_UNQUOTED; + /* Set to TOKENIZE_UNQUOTED or TOKENIZE_UNQUOTED_WHITESPACE */ + ts->state = ts->unquoted_state; } break; diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 4a27c7898c26..71d600c30039 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -1303,6 +1303,14 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, array([('alpha, #42', 10.), ('beta, #64', 2.)], dtype=[('label', '>> s = StringIO('"alpha, #42" 10.0\n"beta, #64" 2.0\n') + >>> dtype = np.dtype([("label", "U12"), ("value", float)]) + >>> np.loadtxt(s, dtype=dtype, delimiter=None, quotechar='"') + array([('alpha, #42', 10.), ('beta, #64', 2.)], + dtype=[('label', '