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

 
 

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

Submitted by:  Colin Foster <cfoster>
Submitted on:  Wed 20 May 2015 11:27:31 PM UTC  
 
Category: LibrariesSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: FixedAssigned to: None
Originator Name: Colin FosterOpen/Closed: Closed
Release: devOperating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

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>
Project 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>
Project 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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by cfoster (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 21 May 2015 10:59:31 PM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Thu 21 May 2015 12:07:41 AM UTCrik5StatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1