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.

Submitted by:  Alois Schlögl <schloegl>
Submitted on:  Thu 11 Apr 2013 08:21:11 PM UTC  
 
Category: LibrariesSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: Patch SubmittedAssigned to: None
Originator Name: Open/Closed: Open
Release: 3.6.4Operating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

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

 

(Jump to the original submission Jump to the original submission)

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

with my newly uploaded tst_null2.csv?

(file #31429)

Rik <rik5>
Project 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>
Sat 19 Apr 2014 01:42:20 AM UTC, comment #6:

Ping!

Michael, can you try

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

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

Ping!

Michael, can you try

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

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

Michael, can you try

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

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

Oops. Now it is attached.

(file #29007)

Rik <rik5>
Project 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>
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.

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>
Project 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 File(s):
   
   
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
  • -unavailable- added by godfrey (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by schloegl (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 12 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 24 May 2014 05:49:21 PM UTCrik5Attached File-=>Added tst_null2.csv, #31429
      Summarydlmread add extra zero line when file contains "\\0" at the end. =>dlmread add extra zero line when file contains "\0" at the end.
    Sat 19 Apr 2014 01:42:20 AM UTCrik5Summarydlmread add extra zero line when file contains "\\0" at the end. =>dlmread add extra zero line when file contains "\0" at the end.
    Mon 21 Oct 2013 04:08:04 PM UTCrik5Summarydlmread add extra zero line when file contains "\\0" at the end. =>dlmread add extra zero line when file contains "\0" at the end.
    Thu 17 Oct 2013 09:40:19 PM UTCrik5StatusNeed Info=>Patch Submitted
      Summarydlmread add extra zero line when file contains "\\0" at the end. =>dlmread add extra zero line when file contains "\0" at the end.
    Wed 04 Sep 2013 09:55:57 PM UTCrik5Attached File-=>Added tst_null.csv, #29007
      Summarydlmread add extra zero line when file contains "\\0" at the end. =>dlmread add extra zero line when file contains "\0" at the end.
    Wed 04 Sep 2013 04:32:07 PM UTCrik5Item GroupIncorrect Result=>Matlab Compatibility
      StatusNone=>Need Info
      Summarydlmread add extra zero line when file contains "\\0" at the end. =>dlmread add extra zero line when file contains "\0" at the end.
    Thu 11 Apr 2013 08:21:11 PM UTCschloeglAttached File-=>Added dlmread-fix-for-0-terminated-file.patch, #27844

    Back to the top


    Powered by Savane 3.1-cleanup