bugGNU Octave - Bugs: bug #31380, textread() lacks format specifier...

 
 

bug #31380: textread() lacks format specifier repeat

Submitter:  Ben Abbott <bpabbott>
Submitted:  Wed 20 Oct 2010 04:10:10 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Fixed Assigned to:  None
Originator Name:  Ben Abbott Open/Closed:  * Closed
Release:  * dev Operating System:  * Mac OS
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 27 Jul 2011 05:32:31 AM UTC, comment #9: 

A bunch more compatibility changes were made in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/f5a3f77d51aa).  The function textread() now supports format specifier repeat.  Closing report.

Rik <rik5>
Group administrator
Sun 24 Jul 2011 11:08:27 PM UTC, comment #8: 

I pushed the changeset.

http://hg.savannah.gnu.org/hgweb/octave/rev/875c735c0929

Pls, let me know if it looks ok.

Ben Abbott <bpabbott>
Group Member
Sun 24 Jul 2011 11:07:06 PM UTC, comment #7: 

With today's latest code fixes on my box (but perhaps it worked before them as well):

octave.exe:94> isequal (strread ('1 2 3 4', '%d', 2), [1; 2])
ans =  1
octave.exe:95>

Hopefully tomorrow I can prepare patches and have a look at the example data2.csv file.

Philip Nienhuis <philipnienhuis>
Group Member
Sun 24 Jul 2011 10:51:21 PM UTC, comment #6: 

To be honest, I didn't check on how texread/scan function.

However, for strreadO on Matlab ...


>> isequal (strread ('1 2 3 4', '%d', 2), [1; 2])
ans =     1


Ben Abbott <bpabbott>
Group Member
Sun 24 Jul 2011 09:20:27 PM UTC, comment #5: 

I think this is actually working.  The documentation for textscan (http://www.mathworks.com/help/techdoc/ref/textscan.html) says that it does not use varargout the way your test is written.  If I rewrite your test to use textread, which does behave the way you expect, than it works.


[Names, Types, x, y, Answer] = textread ("data2.csv", '%s Type%d %f %d %s', 2);


In any case, I just checked in more changes to these functions so you should do an update from Mercurial to changeset 12877:ddea3962b024 before further testing.

Rik <rik5>
Group administrator
Sat 23 Jul 2011 07:07:12 PM UTC, comment #4: 

Opps ... clicked submit too soon.

(file #23687)

Ben Abbott <bpabbott>
Group Member
Sat 23 Jul 2011 07:05:54 PM UTC, comment #3: 

Rik,

I've attached a changeset which fixes the problem with strread.m.

I haven't pushed a changeset since we stopped manually including the ChangeLog entries. Please verify that my changeset is acceptable.

Ben Abbott <bpabbott>
Group Member
Sat 23 Jul 2011 11:29:11 AM UTC, comment #2: 

I don't know if it is a regression, but the multiple output format no longer works.

[A, B, C, ...] = textread (filename, format)

Using the attached "data2.csv", the following doesn't work.


fid = fopen ("data2.csv");
[Names, Types, x, y, Answer] = textscan (fid, '%s Type%d %f %d %s', 2);
fclose (fid);


(file #23685)

Ben Abbott <bpabbott>
Group Member
Fri 22 Jul 2011 08:58:46 PM UTC, comment #1: 

Can you re-verify your issue with a changeset greater than or equal to 12868:b00181c65533?  Although the documentation has not been updated, strread now supports format specifier repeats and so the calling convention textread (filename, format, N) should work.

Rik <rik5>
Group administrator
Wed 20 Oct 2010 04:10:10 AM UTC, original submission:  

Matlab's version allows the format specification to be reused a specified number of times, N.

[A, B, C, ...] = textread (filename, format)
[A, B, C, ...] = textread (filename, format, N)
[...] = textread (..., param, value, ...)

If this functionality is added then it should be straight forward to modify textread() to implement the missing function textscan(). Perhaps it would be proper to rewrite textread() to call textscan().

textscan behaves as ...

C = textscan (fid, 'format')
C = textscan (fid, 'format', N)
C = textscan (fid, 'format', 'param', value)
C = textscan (fid, 'format', N, 'param', value)
C = textscan (str, ...)
[C, position] = textscan (...)

... where C is a cell array ... a concatenation of the outputs for textread().

Ben Abbott <bpabbott>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #23687:  changeset.patch added by bpabbott (2KiB - application/octet-stream - changeset #1)
file #23685:  data2.csv added by bpabbott (86B - 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 philipnienhuis (Posted a comment)
  • -email is unavailable- added by rik5 (Another strread related issue report)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by bpabbott (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-07-27 rik5 StatusNeed Info Fixed
        Open/ClosedOpen Closed
    2011-07-24 rik5 Carbon-Copy- Added philipnienhuis
    2011-07-23 bpabbott Attached File- Added changeset.patch, #23687
    2011-07-23 bpabbott Attached File- Added data2.csv, #23685
    2011-07-22 rik5 StatusNone Need Info
        Summarytextread() is not compatible with Matlab textread() lacks format specifier repeat

    Back to the top

    Powered by Savane 3.14-8eb0.
    Corresponding source code