[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-patch-tracker] [patch #8783] C++ implementation of textscan
From: |
Philip Nienhuis |
Subject: |
[Octave-patch-tracker] [patch #8783] C++ implementation of textscan |
Date: |
Mon, 14 Mar 2016 18:13:44 +0000 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0 SeaMonkey/2.38 |
Follow-up Comment #76, patch #8783 (project octave):
Lachlan,
It's just that to use textscan.cc as backend for strread.m and textread.m,
absence/presence of a trailing EOL matters.
Matlab (at least r2016a prerelease) gives:
w>> format compact
>> textscan (['1 2' char(10) '3'], '%d %f')
ans =
[2x1 int32] [2]
>> textscan (['1 2' char(10) '3' char(10)], '%d %f')
ans =
[2x1 int32] [2x1 double]
>> textscan (['1 2 3' char(10)], '%d %f')
ans =
[2x1 int32] [2x1 double]
>> textscan (['1 2 3'], '%d %f')
ans =
[2x1 int32] [2]
>>
Similarly when reading from file:
>> fid1 = fopen ('txtscn.dat')
fid1 =
3
>> C = textscan (fid1, '%d %d')
C =
[2x1 int32] [2]
>> fclose (fid1);
>> fid2 = fopen ('txtscn2.dat')
fid2 =
3
>> C = textscan (fid2, '%d %d')
C =
[2x1 int32] [2x1 int32]
>>
where txtscn.dat contains "1 2\n3" and txtscn2.dat "1 2\n3\n".
This behavior is the same as that of Matlab's strread:
>> [a, b] = strread ('1 2 3', '%d %d')
a =
1
3
b =
2
>> [a, b] = strread (['1 2 3' char(10)], '%d %d')
a =
1
3
b =
2
0
%% note int32 has no NaN so here we get 0
>> [a, b] = strread (['1 2' char(10) '3'], '%d %d')
a =
1
3
b =
2
>> [a, b] = strread (['1 2' char(10) '3' char(10)], '%d %d')
a =
1
3
b =
2
0>>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/patch/?8783>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, (continued)
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Lachlan Andrew, 2016/03/07
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Ben Abbott, 2016/03/07
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Philip Nienhuis, 2016/03/07
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Philip Nienhuis, 2016/03/07
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Ben Abbott, 2016/03/07
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Philip Nienhuis, 2016/03/10
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Philip Nienhuis, 2016/03/13
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Ben Abbott, 2016/03/13
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, John W. Eaton, 2016/03/13
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Lachlan Andrew, 2016/03/13
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan,
Philip Nienhuis <=
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Philip Nienhuis, 2016/03/14
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Ben Abbott, 2016/03/14
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Lachlan Andrew, 2016/03/15
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Philip Nienhuis, 2016/03/15
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, John W. Eaton, 2016/03/15
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Philip Nienhuis, 2016/03/15
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Philip Nienhuis, 2016/03/15
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Philip Nienhuis, 2016/03/15
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Lachlan Andrew, 2016/03/15
- [Octave-patch-tracker] [patch #8783] C++ implementation of textscan, Philip Nienhuis, 2016/03/15