bugGNU Octave - Bugs: bug #49830, xlsread difference vs. matlab

 
 

bug #49830: xlsread difference vs. matlab

Submitter:  Steven Weinberg <wstevena>
Submitted:  Mon 12 Dec 2016 10:09:24 PM UTC
   
 
Category:  Octave Function Severity:  1 - Wish
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Postponed Assigned to:  None
Originator Name:  steve weinberg Open/Closed:  * Open
Release:  * other Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 20 Mar 2018 06:30:47 PM UTC, comment #2: 

These days (IIRC using io > 2.4.9) you can get Matlab's behavior by using a 5th argument to xlsread.m:

:
>> [a, b, c] = xlsread ('test1.xlsx', 4, "c2:f7", "poi", struct ("strip_array", 0))
a =

   0.010000   0.010000   0.010000   0.010000

b = {}(0x0)
c =
{
  [1,1] = [](0x0)
  [2,1] = [](0x0)
  [3,1] =  0.010000
  [4,1] = [](0x0)
  [5,1] = [](0x0)
  [6,1] = [](0x0)
  [1,2] = [](0x0)
  [2,2] = [](0x0)
  [3,2] =  0.010000
  [4,2] = [](0x0)
  [5,2] = [](0x0)
  [6,2] = [](0x0)
  [1,3] = [](0x0)
  [2,3] = [](0x0)
  [3,3] =  0.010000
  [4,3] = [](0x0)
  [5,3] = [](0x0)
  [6,3] = [](0x0)
  [1,4] = [](0x0)
  [2,4] = [](0x0)
  [3,4] =  0.010000
  [4,4] = [](0x0)
  [5,4] = [](0x0)
  [6,4] = [](0x0)
}


If / when the spreadsheet I/O is going to core (some day, some time) this could be made the default behavior.

Philip Nienhuis <philipnienhuis>
Group Member
Tue 13 Dec 2016 06:01:50 PM UTC, comment #1: 

IMO returning NaNs for empty cells using xlsread is a stupidity of Matlab caused by legacy behavior inherited from old Excel versions. TTBOMK earlier versions of matlab used to return yet other bit patterns than NaN.

I think you can get similar results by using this:

xls = xlsopen ('test1.xlsx');
c = xls2oct (xls, 'restrictions','c2:f7', struct ('strip_array', 0));
xls = xlsclose (xls);
[a, b] = parsecell (c);

No NaNs yet but empty cells. To get NaNs you'd do:

c(cellfun (@isempty, c)) = NaN;

Or, you can use the fourth return arg of xlsread to fix up c (type "help xlsread")

I'm (yet) not quite in favor of "fixing" this.

Setting status => postponed and lowering priority

Philip Nienhuis <philipnienhuis>
Group Member
Mon 12 Dec 2016 10:09:24 PM UTC, original submission:  

Matlab:


[a,b,c] = xlsread('test1.xlsx','restrictions','c2:f7')

a =

         0.01         0.01         0.01         0.01


b =

     {}


c =

    [ NaN]    [ NaN]    [ NaN]    [ NaN]
    [ NaN]    [ NaN]    [ NaN]    [ NaN]
    [0.01]    [0.01]    [0.01]    [0.01]
    [ NaN]    [ NaN]    [ NaN]    [ NaN]
    [ NaN]    [ NaN]    [ NaN]    [ NaN]
    [ NaN]    [ NaN]    [ NaN]    [ NaN]

Octave:

[a,b,c] = xlsread('test1.xlsx','restrictions','c2:f7')
a =

   0.010000   0.010000   0.010000   0.010000

b = {}(0x0)
c =
{
  [1,1] =  0.010000
  [1,2] =  0.010000
  [1,3] =  0.010000
  [1,4] =  0.010000


The difference in the third output, c, is causing problems. I am using io 2.4.5. 



Steven Weinberg <wstevena>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #39206:  test1.xlsx added by wstevena (9KiB - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by wstevena (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-03-20 mtmiller CategoryNone Octave Function
    2016-12-13 philipnienhuis CategoryOctave Package None
        Severity3 - Normal 1 - Wish
        StatusNone Postponed
        Release4.2.0 other
    2016-12-12 wstevena Attached File- Added test1.xlsx, #39206

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code