bugGNU Octave - Bugs: bug #45156, csvread and dlmread return errors...

 
 

bug #45156: csvread and dlmread return errors when reading an empty file

Submitter:  Colin Foster <cfoster>
Submitted:  Wed 20 May 2015 11:27:31 PM UTC
   
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Fixed Assigned to:  None
Originator Name:  Colin Foster Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 21 May 2015 10:59:31 PM UTC, comment #3: 

I made a change, almost what you proposed, here (http://hg.savannah.gnu.org/hgweb/octave/rev/ca2da088eada).  The change was made on the stable branch so this will be a part of the 4.0.0 release.

Rik <rik5>
Group administrator
Thu 21 May 2015 12:14:54 AM UTC, comment #2: 

I'm having trouble compiling (library issues... on a new computer)

Here's the fix I propose, which is kindof a hack but I don't see it causing any issues


colin@euler:octave$ hg diff
diff -r abf85f8cbd6c libinterp/corefcn/dlmread.cc
--- a/libinterp/corefcn/dlmread.cc Wed May 20 08:01:10 2015 -0700
+++ b/libinterp/corefcn/dlmread.cc Wed May 20 19:12:32 2015 -0500
@@ -474,16 +474,19 @@
       if (c1 >= c)
         c1 = c - 1;
 
-      // Now take the subset of the matrix.
-      if (iscmplx)
-        cdata = cdata.extract (0, c0, r1, c1);
-      else
-        rdata = rdata.extract (0, c0, r1, c1);
+      // Now take the subset of the matrix, if we have at least one value
+      if (i > 0 || j > 0)
+      {
+        if (iscmplx)
+          cdata = cdata.extract (0, c0, r1, c1);
+        else
+          rdata = rdata.extract (0, c0, r1, c1);
 
-      if (iscmplx)
-        retval(0) = cdata;
-      else
-        retval(0) = rdata;
+        if (iscmplx)
+          retval(0) = cdata;
+        else
+          retval(0) = rdata;
+      }
     }
 
   return retval;

Colin Foster <cfoster>
Thu 21 May 2015 12:07:41 AM UTC, comment #1: 

Confirmed.  It would be nice to see what Matlab does, but returning an empty matrix does seem sensible.

Rik <rik5>
Group administrator
Wed 20 May 2015 11:27:31 PM UTC, original submission:  

When running csvread on an empty file (created by `touch ~/empty.csv`) the dlmread function returns with an error.

I am not sure how MATLAB responds to this, but I would expect proper functionality would be to return an empty matrix.

I have created a patch for this and will include it in my next post. I'm currently pulling the updated source and, after verifying, will submit it.

Colin Foster <cfoster>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by cfoster (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-05-21 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-05-21 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code