Sun 16 Aug 2015 02:41:19 PM UTC, comment #11:
OK, I've pushed a cs on stable improving (hopefully) the usage of whitespace and delimiter params:
http://hg.savannah.gnu.org/hgweb/octave/rev/d43675752d04
|
Sat 15 Aug 2015 01:29:21 PM UTC, comment #10:
The meaning of "trimmed" is not clear to me. If it means that consecutive consecutive whitespaces are collapsed to one, I think this should be explicitly stated, more so as it looks strange to me that whitespaces are collapsed in the presence of %s specifiers.
Thank you for following up on this. By the way, I may not be able to follow this discussion in the next couple of weeks.
|
Sat 15 Aug 2015 01:00:20 PM UTC, comment #9:
Turns out is is mentioned in the texinfo help, but maybe not so clear.
What about the following?
|
Sat 15 Aug 2015 08:43:52 AM UTC, comment #8:
Sure, I agree it would be helpful. But because large parts of whitespace/delimiter behavior in Matlab is un-/poorly documented it would become a long-winding and perhaps even ambiguous explanation.
I'll think about it.
|
Fri 14 Aug 2015 04:21:56 PM UTC, comment #7:
Would it be possible to clarify the description? I would propose a text myself, but in fact I have not understood what should be changed. Maybe a concise version of your explanation would do?
|
Fri 14 Aug 2015 03:38:46 PM UTC, comment #6:
I've pushed a slightly modified cs (simplified test) here:
http://hg.savannah.gnu.org/hgweb/octave/rev/4c4d8fe5583a
closing report.
|
Thu 13 Aug 2015 08:20:13 PM UTC, comment #5:
As to whitespace, that's a bit of an opaque issue.
From what I understand, if you do not specify a value for it, whitespace is usually added to the delimiters, unless a "%s" specifier is in the format string. See here:
http://nl.mathworks.com/help/matlab/ref/strread.html
Indeed, first of all multiple consecutive whitespace is usually collapsed. To some extent even "trimmed", if there's an adjacent delimiter.
Delimiters aren't collapsed, unless param "multipledelimsasone" is given with value true.
The functional distinction/relation between delimiters and whitespace is more complicated than described above and poorly documented.
Next, the string is split on delimiter occurrences.
The next step then in strread.m is trying to match the format string to the (usually first line of the) data. That serves as a first check but also inits several variables needed for ensuing steps.
In those further steps, a.o., fields immediately bordering literals and other fields are separated (e.g., "...1.5abc..." with fmt specs "...%f%s..." or "...%fabc..."). Think of ~ "virtual delimiters".
All in all the code is quite messy, but most of that is due to the way strread.m has been vectorized to the limit.
We do need a binary replacement; it was thought a binary textscan() could replace strread.m's innards but no one has come up with a working function yet.
|
Thu 13 Aug 2015 12:36:55 PM UTC, comment #4:
Thanks. I would also appreciate a clarification of the meaning of the "whitespace" parameter.
I understand that the first step in parsing is "collapsing to a asingle space" (not "trimming") all sequences of whitespace characters. Then separators are searched and words identified.
But I am just guessing, and I suspect the guess is not accurate.
|
Sun 09 Aug 2015 09:31:43 PM UTC, comment #3:
Easier than I figured, luckily.
Patch attached. I'll push to stable (as this is a mere bug fix) within a few days if no one objects.
(file #34615)
|
Sat 08 Aug 2015 09:22:14 PM UTC, comment #2:
Matlab r2015b prerelease doesn't need the whitespace parameter.
I'm not sure if this is easy to fix, but I'll have a look one of these days (if someone else doesn't beat me).
At least there is a workaround.
OS->Any, Release->dev
|
Fri 07 Aug 2015 04:30:18 PM UTC, comment #1:
Did you want to get this?
|
Fri 07 Aug 2015 12:47:07 PM UTC, original submission:
This is correct:
>> [a b c d] = strread("14 :5 z:11:-15:1", "%f%s%f%f%*", 'delimiter', ":")
a = 14
b =
{
[1,1] = 5 z
}
c = 11
d = -15
Now trying, and failing, to ignore the second word:
>> [a c d] = strread("14 :5 z:11:-15:1", "%f%s%f%f%", 'delimiter', ":")
a =
14
1
c = NaN
d = 11
strread reads 14, then reads "5" and "z" as two different words, using space as a delimiter rather than colon.
Maybe this has to do with the string beginning with a digit, or containing a space, sorry, did not investigate further.
|