Date: Oct 22, 2013 5:11 PM
Author: dpb
Subject: Re: textread/textscan not reading formatted text with whitespace

On 10/22/2013 2:56 PM, Norbert Marwan wrote:
> dpb <none@non.net> wrote in message <l462ri$s24$1@speranza.aioe.org>...
...

>> Actually, I don't see why the regexp() folderol...with fixed-width
>> fields simplest and quickest would be to simply insert the comma in
>> the appropriate columns w/ strrep() or similar direct manipulation.
>> Looks like complexity for the sake of showing cleverness???
>>

...

> because it is much slower for long data files with ten-thousends of
> lines. the from the support suggested solution is much faster, but not
> as fast as textread can be.


You're saying the above regexp() solution is faster than

strrep(s(:,4),s(:,4),[s(:,4 ','])

or

[s(:,4) char(ones(3,1)*',') ... ]

where the comma column is predefined? That's surprising.

> i wonder why the '(....)(..)(..)(...)(...)' is not applicable to
> textread or textscan. this would also help. but noooo, this would be too
> simple.


Because it isn't at all related to C i/o format scanning; regular
expressions are their own thing independent thereof. That part I do
understand fully; it would be, imo, _a_bad_thing_ (tm) to try to fold
them together adding generally unwanted complexity to the most mundane
as a cost.

The answer is that there really should be another class of i/o functions
that _are_ based on the FORMAT scanning instead of C-like fscanf() and
friends.

That one, unfortunately, just doesn't look like it's ever going to
happen outside the File Exchange, perhaps, by someone younger (or at
least more energetic) than I am any longer...

--