bugGNU Octave - Bugs: bug #42022, dlmread: A(I,J): column index out...

 
 

bug #42022: dlmread: A(I,J): column index out of bounds; value 2 out of bound 1

Submitted by:  Philip Nienhuis <philipnienhuis>
Submitted on:  Tue 01 Apr 2014 07:48:38 PM UTC  
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Philip Nienhuis Open/Closed:  Closed
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

( Jump to the original submission)

Sun 23 Oct 2016 07:09:04 PM UTC, comment #6: 

Octave already accepts the form "<delimiter>NUMBER" so I think this bug can be closed.

Rik <rik5>
Project Administrator
Fri 14 Oct 2016 03:59:31 PM UTC, comment #5: 

Shouldn't Octave also take into account patterns of the form "<delimiter>NUMBER", to interpret empty fields preceding a delimiter?
After my experiences with strread/textscan some years ago I'm ready to accept a wide range of input file contents :-)

(It made me a little bit happy to see that Octave performed better than the competition ;-) )

Philip Nienhuis <philipnienhuis>
Project Member
Fri 14 Oct 2016 02:04:55 PM UTC, comment #4: 

This is what I thought.  dlmread in Octave is also coded to expect numeric input.  When you do not specify a delimiter, Octave has to search the file to find one and it is looking for a pattern of "NUMBER<delimiter>".  The file in this bug report is "TEXT,NUMBER" so Octave finds the end of line character rather than a delimiter and concludes that there is only one column of data.

We could try relaxing the constraint to be "ANY_TEXT<delimiter>".  I don't know what other effects that might have, although 'make check' still passes.  I made that change here http://hg.savannah.gnu.org/hgweb/octave/rev/e7699adac1d0.  I'm going to mark this report as Ready for Test, and will leave it open for a while since I'm not certain that this won't introduce other subtle bugs later.

Rik <rik5>
Project Administrator
Fri 14 Oct 2016 12:40:47 PM UTC, comment #3: 

(Just intermediate result, I have had no time to dive into importdata.m again, so here are just Matlab results)

Matlab r2016b gives:

>> dlmread ('bug42022.txt', '')
Error using dlmread (line 147)
Mismatch between file and format character vector.
Trouble reading 'Numeric' field from file (row number 1, field number 1) ==> aaaa,11\n

Note that Matlab doesn't accept 'emptyvalue'. Specifying a comas as separator makes no difference.

Octave-4.3.0+ does (specifying a comma as delimiter, ):

>> dlmread ("bug42022.txt", ",", 0, 1, "emptyvalue", NaN)
ans =

    11
   NaN
    33

which looks to be all right if not better than expected or Matlab (given that dlmread cannot read non-numeric data).

Specifying an empty string (indicating dlmread should assess the delimiter itself) gives:

>> dlmread ("bug42022.txt", "", 0, 1, "emptyvalue", NaN)
error: index (_,2): but object has size 6x1

so dlmread apparently has trouble finding out the separator character.

Philip Nienhuis <philipnienhuis>
Project Member
Wed 12 Oct 2016 07:44:41 PM UTC, comment #2: 

IIRC, and based on reading the importdata.m's bug report (bug #41630) that triggered this report, I'd need to check importdata's behavior again.
So yes, dlmread is used outside its specs, but that may be due to importdata.m.
Tomorrow I hope to have a chance to check w. Matlab.

Philip Nienhuis <philipnienhuis>
Project Member
Wed 12 Oct 2016 03:27:37 PM UTC, comment #1: 

What does Matlab do for the same input?

I've checked the code in dlmread.cc and the issue is that dlmread is built to read only numeric data.  The documentation from Matlab is also clear that the function is only for numeric data (http://www.mathworks.com/help/matlab/ref/dlmread.html).

I agree it would be nice to have a better warning message, but it also might not be worth fixing since this is a corner case and the function is not being used according to its docstring so all bets are off.

Rik <rik5>
Project Administrator
Tue 01 Apr 2014 07:48:38 PM UTC, original submission:  

While trying to fix importdata.m (see bug #41630) I hit some errors with dlmread.

File imp3.txt:

aaaa,11
bbbb,
cccc,33

(note trailing space on line 2 after comma)

>> dlmread ('imp3.txt', '', 0, 1, 'emptyvalue', NaN)
error: dlmread: A(I,J): column index out of bounds; value 2 out of bound 1

The bug is that dlmread shouldn't error out but rather emit a sensible error message.

Philip Nienhuis <philipnienhuis>
Project Member

 

(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 nul0m
  • -email is unavailable- added by philipnienhuis (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-10-23 rik5 StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    2016-10-14 rik5 StatusNone => Ready For Test
    2014-05-11 nul0m Carbon-Copy- => Added nul0m

    Back to the top


    Powered by Savane 3.5