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

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

[Octave-bug-tracker] [bug #57812] xlsread imports accounting negative nu


From: Ben Stanley
Subject: [Octave-bug-tracker] [bug #57812] xlsread imports accounting negative numbers as NaN
Date: Fri, 14 Feb 2020 19:28:47 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/79.0.3945.130 Chrome/79.0.3945.130 Safari/537.36

Follow-up Comment #3, bug #57812 (project octave):

Digging deeper the problem appears to be in __OCT_ods2oct__.m .

The following lines fail to make the correct conversion.

                case "float"
                  ## Watch out for error values. If so, <text> has #VALUE and
office:value = 0
                  if (isfinite (str2double (ctvalue)))
                    rawarr{irow, icol} = str2double (getxmlattv (tcell,
"office:value"));
                  else
                    rawarr{irow, icol} = NaN;
                  endif

For Example.ods, ctvalue="(1,234)"
str2double fails
Note however that the XML attribute office:value="-1234" and str2double would
succeed.

I changed the test line to use regexp to look for the error values, instead of
trying to convert the ctvalue to a number using str2double :
                  if isempty(regexp(ctvalue,'^#[A-Z]+$'))

After this change, my test case appears to work for me:

>> pkg load io;
>> [numarr,txtarr,rawarr,limits]=xlsread('Example.ods')

OpenJDK 64-Bit Server VM warning: Archived non-system classes are disabled
because the java.system.class.loader property is specified (value =
"org.octave.OctClassLoader"). To use archived non-system classes, this
property must be not be set
Detected XLS interfaces: numarr = -1234
txtarr = {}(0x0)
rawarr =
{
  [1,1] = -1234
}
limits =

  scalar structure containing the fields:

    numlimits =

       1   1
       1   1

    txtlimits = [](0x0)
    rawlimits =

       1   1
       1   1


>>

With this change, I am also able to read a cell with the formula
=2/0
and has the text
#DIV0
reads in to octave numarr as
NaN



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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