bugGNU Octave - Bugs: bug #58942, [octave forge] (io) version 2.6.1...

 
 

bug #58942: [octave forge] (io) version 2.6.1 read cell range data from worksheet

Submitted by:  None
Submitted on:  Wed 12 Aug 2020 06:07:42 PM UTC  
 
Category:  Octave Forge Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Need Info Assigned to:  None
Originator Name:  Carlos Obiglio Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  4.4.1
Operating System:  Microsoft Windows

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 04 Sep 2020 03:34:50 PM UTC, comment #4: 

Ping ....

@OP (Carlos):
Can you please explain what bug you saw, and how your patch will fix that bug? Do you have a reproducible scenario?

AFAIU there are a few intermingled things in your report:

  • You got an error message "error: xls2oct: worksheet number 1 > number of worksheets in file (0)"

That implies that xls2oct.m didn't find a worksheet. AFAICS the only way that can happen is if you opened a new file, didn't add any data to it and then tried to read from it.

  • Your patch allows to skip specifying a worksheet in xls2oct.m; the same is done in xlsread.m so there's already a similar mechanism in place. I'm not fond of having similar measures in different parts of the io package code base.

I'm afraid that if you hit a real bug your fix is just fixing symptoms but not a real fix for the underlying issue.

As I couldn't detect any issues in the io package code I intend to close this report with "invalid" but I wouldn't want to let a real bug pass into a next io package release.

Philip Nienhuis <philipnienhuis>
Project Member
Thu 13 Aug 2020 06:35:59 PM UTC, comment #3: 

Oh you have version 2.6.1, sorry for my ignorance.

Still my question for an example stands.

Philip Nienhuis <philipnienhuis>
Project Member
Thu 13 Aug 2020 06:35:05 PM UTC, comment #2: 

Thanks Carlos for your patch.

I'm unsure what issue your patch is meant to solve. Can you explain, please?
Can you also tell us which io package version you use?
just do "pkg list io" and you get something like this:

>> pkg list io
Package Name  | Version | Installation directory
--------------+---------+-----------------------
          io *|   2.6.2 | ... <some long path name> ...

where (in this exaample) 2.6.2 is the io package version.

The error message you mention comes from private function __OCT_xlsx2oct__.m which will only be invoked when using the OCT spreadsheet I/O interface. However your patch would apply for all interfaces. I'm not sure if that is a good idea.

That said, that error message exists for a reason. It simply says that if you want to read from e.g., the 4th worksheet while there are only 3 worksheets in the file, you want to do something impossible.
I don't see how that relates to the magic you want to apply to xls2oct.m's input arguments.

Furthermore, you give an example using xlsread.m showing a range as second argument rather than a worksheet. But that very logic has been there in xlsread.m from the beginning in around 2009 (have a look at xlsread.m L.271 and up).
If that doesn't work for you out of the box I'd be very happy if you could supply an example that shows the error.

Philip Nienhuis <philipnienhuis>
Project Member
Thu 13 Aug 2020 01:50:27 AM UTC, comment #1: 

Thank you very much for your contribution Carlos Obiglio 🙂  I updated the title and polished the changes of your file to a proper patch and it looks useful.  Maybe Philip considers your changes soon, he is the expert.

--- io-2.6.1/xls2oct.m        2020-07-14 13:10:28.635507529 +0900
+++ xls2oct.m        2020-08-13 10:43:34.960845328 +0900
@@ -121,8 +121,16 @@

## Author: Philip Nienhuis <prnienhuis at users.sf.net>
## Created: 2010-10-16

-function [ rawarr, xls, rstatus ] = xls2oct (xls, wsh=1, datrange="", spsh_opts=[])
+function [ rawarr, xls, rstatus ] = xls2oct (xls, wsh, datrange="", spsh_opts=[])
+  if (nargin == 1)
+    wsh = 1;
+    wwsh = 1;
+  endif
+  if (nargin > 1 && ~isempty (wsh))
+    wwsh = wsh;
+  else
+    wwsh = 0;
+  endif

   ## Check if xls struct pointer seems valid
   if (! isstruct (xls))
@@ -150,7 +158,11 @@
   elseif (! isempty (datrange))
     ## Check for range name and convert it to range & optionally sheet 1.
     ## Check if it matches a range
-    [datrange, wsh, xls] = chknmrange (xls, datrange, wsh);
+    if (ischar (wwsh) || wwsh > 0)
+      [datrange, wsh, xls] = chknmrange (xls, datrange, wwsh);
+    else
+      [datrange, wsh, xls] = chknmrange (xls, datrange, wsh);
+    endif
   endif

   ## Check & setup options struct
@@ -216,6 +228,7 @@
     case "OCT"
       ## Read xls file thru native Octave
       if (strcmpi (xls.app, "xlsx"))
+        xls.sheets.sh_names = wsh;
         [rawarr, xls, rstatus] = __OCT_xlsx2oct__ (xls, wsh, datrange, spsh_opts);
       elseif (strcmpi (xls.app, "gnumeric"))
         [rawarr, xls, rstatus] = __OCT_gnm2oct__ (xls, wsh, datrange);

Kai Torben Ohlhus <siko1056>
Project Member
Wed 12 Aug 2020 06:07:42 PM UTC, original submission:  

 Sir: I have done a fix for the problem (see error below)
----------------------------------------------------------------
error: xls2oct: worksheet number 1 > number of worksheets in file (0)
----------------------------------------------------------------
I attach the pgm  xls2oct with the fix, you can find with
 " modifica x Charlie Obiglio ".
----------------------------------------------------------------
This fix allow to Read data contained within cell range RANGE from worksheet WSH in a spreadsheet file pointed to in struct XLS.
 I did the tests with a spreadsheet (Google) and it works well, taking the range of cells of the leftmost work sheet, it does not needs to inform the work sheet.
example :[ num text cell ] = xlsread ( excelFileName,"c1:f5" ). 

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #49661:  xls2oct.m added by None (12KiB - application/vnd.wolfram.mathematica.package - ok thats all. )

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by philipnienhuis
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-08-13 philipnienhuis StatusPatch Submitted => Need Info
        Carbon-Copy- => Added philipnienhuis
    2020-08-13 siko1056 StatusNone => Patch Submitted
        SummaryPackage I0-2.6.1 Input/Output => [octave forge] (io) version 2.6.1 read cell range data from worksheet
    2020-08-12 None Attached File- => Added xls2oct.m, #49661

    Back to the top


    Powered by Savane 3.5