bugGNU Octave - Bugs: bug #38711, dlmread add extra zero line when...

 
 

bug #38711: dlmread add extra zero line when file contains "\0" at the end.

Submitter:  Alois Schlögl <schloegl>
Submitted:  Thu 11 Apr 2013 08:21:11 PM UTC
   
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Wont Fix Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 3.6.4 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 01 Jul 2016 04:06:25 AM UTC, comment #10: 

I don't think we need to change this.  We are already more than Matlab compatible.  Closing report.

Rik <rik5>
Group administrator
Fri 01 Jul 2016 01:42:56 AM UTC, comment #9: 


>> version
ans =
8.2.0.701 (R2013b)
>> x = dlmread ('/tmp/tst_null2.csv', ',')
Error using dlmread (line 139)
Mismatch between file and format string.
Trouble reading number from file (row 3u, field 1u) ==>


(Note that the line after ==> has a single space in it.)

It looks Matlab can't read files with \0 at all.  That is consistent with the help, which says


All data in the input file must be numeric. dlmread does not operate
on files containing nonnumeric data, even if the specified rows and
columns for the read contain numeric data only.


It seems we are unconstrained by Matlab compatibility on this one.

Lachlan Andrew <lachlan>
Sat 24 May 2014 05:49:21 PM UTC, comment #8: 

Not at all what I expected.  What if the NULL character is really the last entry in the file?  Can you try


x = dlmread ('tst_null2.csv', ',')


with my newly uploaded tst_null2.csv?


(file #31429)

Rik <rik5>
Group administrator
Sat 24 May 2014 05:21:04 PM UTC, comment #7: 

Matlab says:

>> x = dlmread ('tst_null.csv', ',')

??? Error using ==> dlmread at 145
Mismatch between file and format string.
Trouble reading number from file (row 2, field 1) ==>
 

>> version


ans =

7.9.0.529 (R2009b)

>>


Michael Godfrey <godfrey>
Group Member
Sat 19 Apr 2014 01:42:20 AM UTC, comment #6: 

Ping!

Michael, can you try


x = dlmread ('tst_null.csv', ',')


with the attached "tst_null.csv" and see what Matlab returns?

Rik <rik5>
Group administrator
Mon 21 Oct 2013 04:08:04 PM UTC, comment #5: 

Ping!

Michael, can you try


x = dlmread ('tst_null.csv', ',')


with the attached "tst_null.csv" and see what Matlab returns?

Rik <rik5>
Group administrator
Thu 17 Oct 2013 09:40:19 PM UTC, comment #4: 

Michael, can you try


x = dlmread ('tst_null.csv', ',')


with the attached "tst_null.csv" and see what Matlab returns?

Rik <rik5>
Group administrator
Wed 04 Sep 2013 09:55:57 PM UTC, comment #3: 

Oops.  Now it is attached.

(file #29007)

Rik <rik5>
Group administrator
Wed 04 Sep 2013 08:22:32 PM UTC, comment #2: 

 I've attached a file tst_null.csv that I would like someone to read in with Matlab.

Could not find the file.  Did you really attach it?

Michael Godfrey <godfrey>
Group Member
Wed 04 Sep 2013 04:32:07 PM UTC, comment #1: 

Do you have access to Matlab?  I'm wondering how they treat null lines both within the data and at the end of the file.  I've attached a file tst_null.csv that I would like someone to read in with Matlab.


x = dlmread ('tst_null.csv', ',')


Is the null line in the middle of the file transformed into "0 0 0"?  There are two null lines at the end of the file.  Are they both eliminated?  Or is one retained as "0 0 0" and only the last line of the file eliminated if it contains '\0'.

Rik <rik5>
Group administrator
Thu 11 Apr 2013 08:21:11 PM UTC, original submission:  


Some csv files generated by some other software, contained a "\0" before the end of file. When trying to read this file, an extra row with zeros has been added to the resulting matrix.

The attached patch shows the problem in the test/assert statement, and provides a solution.

Other solutions than "if(!strlen(line.c_str()))" did not seem to be successful. line.length() is 1, and line.empty() was zero. when the line "\0" was read.




Alois Schlögl <schloegl>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #31429:  tst_null2.csv added by rik5 (14B - text/csv)
file #29007:  tst_null.csv added by rik5 (18B - text/csv)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by lachlan (Updated the item)
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by schloegl (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 15 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-07-01 rik5 StatusPostponed Wont Fix
        Open/ClosedOpen Closed
    2016-06-30 lachlan StatusPatch Submitted Postponed
    2014-05-24 rik5 Attached File- Added tst_null2.csv, #31429
        Summarydlmread add extra zero line when file contains &quot;\\0&quot; at the end. dlmread add extra zero line when file contains "\0" at the end.
    2014-04-19 rik5 Summarydlmread add extra zero line when file contains &quot;\\0&quot; at the end. dlmread add extra zero line when file contains "\0" at the end.
    2013-10-21 rik5 Summarydlmread add extra zero line when file contains &quot;\\0&quot; at the end. dlmread add extra zero line when file contains "\0" at the end.
    2013-10-17 rik5 StatusNeed Info Patch Submitted
        Summarydlmread add extra zero line when file contains &quot;\\0&quot; at the end. dlmread add extra zero line when file contains "\0" at the end.
    2013-09-04 rik5 Attached File- Added tst_null.csv, #29007
        Summarydlmread add extra zero line when file contains &quot;\\0&quot; at the end. dlmread add extra zero line when file contains "\0" at the end.
    2013-09-04 rik5 Item GroupIncorrect Result Matlab Compatibility
        StatusNone Need Info
        Summarydlmread add extra zero line when file contains &quot;\\0&quot; at the end. dlmread add extra zero line when file contains "\0" at the end.
    2013-04-11 schloegl Attached File- Added dlmread-fix-for-0-terminated-file.patch, #27844

    Back to the top

    Powered by Savane 3.13-cf05.
    Corresponding source code