octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #60711] textscan with '.' char read as float


From: Rik
Subject: [Octave-bug-tracker] [bug #60711] textscan with '.' char read as float
Date: Tue, 1 Jun 2021 20:02:50 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36

Update of bug #60711 (project octave):

        Operating System:       Microsoft Windows => Any                    

    _______________________________________________________

Follow-up Comment #1:

There is a difference with Matlab, but Matlab's approach doesn't make as much
sense to me as Octave's.

Take a slightly different example for illustrative purposes.


q=textscan([',,2,,'],'%f','delimiter',',', 'emptyvalue', -1)


I specifically set the EmptyValue option to something besides NaN so the
processing of textscan is more obvious.  In both Octave and Matlab this
returns


q =
{
  [1,1] =

    -1
    -1
     2
    -1

}


This makes sense to me.  There is a missing value at the start of the string,
the second position is also missing, the third value is the number 2, and then
then there is another missing value.

Now try reading just a single '.' character.


textscan ('.', '%f')


Both Octave and Matlab return [] for this.

Based on this data, I would expect that ',,.,,' would be treated as EmptyValue
EmptyValue EmptyValue EmptyValue which is exactly what Octave does.  I'm not
sure why Matlab decides there are two values here when the delimiter was
clearly specified to be the comma ','.

Of course, if you have built your textscan parser to rely on this
Matlab-specific behavior then it will be a problem.  A simple hack would be to
use regular expressions and search&replace bare instances of '.' with
something else including possibly nothing.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60711>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]