The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: textscan: handling spaces in fixed-width data
Replies: 5   Last Post: Jan 7, 2013 10:36 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 9,850
Registered: 6/7/07
Re: textscan: handling spaces in fixed-width data
Posted: Jan 7, 2013 10:36 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 1/7/2013 6:46 AM, David wrote:
> Hi dpb, Thanks for your messages! It really appears strange, that
> textscan handles the space different than other characters while scanning.


It's an unfortunate wart that comes from Matlab being written in C and
therefore using the *scanf() functions in the C i/o library and runtime.

I finally did find the normative text in the C Standard so it can't even
be blamed on a bad implementation; it's the result of a (misguided imo)
choice in the language definition to "eat" white space on the apparent
assumption that all input should be delimited--

From the C99 Standard (C99

> Input white-space characters (as specified by the isspace function)
> are skipped, unless the specification includes a [, c, or n
> specifier.241)

I've commented for years about not having an alternate Fortran-like
FORMAT specification that would solve many of the problems w/ the C
format strings (like also not being able to have repeat specifiers but
having to resort to the butt-ugly repmat() nonsense) that would fix the
problem but the seeds have fallen upon barren ground it seems...


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.