bugGNU Octave - Bugs: bug #53914, textread / strread incorrectly...

 
 

bug #53914: textread / strread incorrectly reads string

Submitted by:  Muhali <muhali>
Submitted on:  Tue 15 May 2018 07:32:43 PM UTC  
 
Category:  Octave Function Severity:  3 - Normal
Priority:  3 - Low Item Group:  None
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
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.

 

Wed 16 May 2018 07:41:10 PM UTC, comment #3:

The culprit is in L.422+ of strread.m

To solve this we'd need to know exactly how Matlab treats different whitespace chars in presence of %s format specifiers.

Philip Nienhuis <philipnienhuis>
Project Member
Wed 16 May 2018 08:54:21 AM UTC, comment #2:

no problem. Go ahead lowering priority. Thanks.

Muhali <muhali>
Wed 16 May 2018 08:27:24 AM UTC, comment #1:

Try this (FYI strread is the backend of textread):

In general, when reading strings containing spaces using textread/strread/textscan, specify '"whitespace", ""' to avoid spaces being left in the whitespace (= default delimiter) collection.

Matlab r2017b does a slightly better job with strread/testread, however its textscan does the same as Octave's.
As TMW advises to not use textread/strread but invoke textscan instead I don't think we'll do much about strread.m.
I did a lot of work at strread.m some years ago, I'm afraid that fixes for this type of rare corner cases will require undue amounts of extra code.

Would you agree to just lower priority, as there's a good workaround?

Philip Nienhuis <philipnienhuis>
Project Member
Tue 15 May 2018 07:32:43 PM UTC, original submission:

suppose the file foo.txt contains the single line

# #

When reading the file via

one gets, however,

a =
{
[1,1] = # #
}

which misses one space. When doing instead

one correctly gets

a =
{
[1,1] =
{
[1,1] = # #
}

}

Muhali <muhali>

 

(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 muhali (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.

     

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

     

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    Thu 17 May 2018 10:13:04 PM UTC mtmiller Carbon-CopyRemoved 80942 => -
    Thu 17 May 2018 10:11:48 PM UTC mtmiller CategoryNone => Octave Function
    Wed 16 May 2018 07:41:10 PM UTC philipnienhuis Priority5 - Normal => 3 - Low
    Wed 16 May 2018 08:27:24 AM UTC philipnienhuis StatusNone => Confirmed
        Release4.4.0 => dev
        Operating SystemGNU/Linux => Any
        Summarytextread incorrectly reads string => textread / strread incorrectly reads string

    Back to the top


    Powered by Savane 3.3