[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #41579] textscan: file offset after partial re
From: |
Philip Nienhuis |
Subject: |
[Octave-bug-tracker] [bug #41579] textscan: file offset after partial read differs from Matlab |
Date: |
Tue, 24 Oct 2017 03:04:25 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0 SeaMonkey/2.48 |
Follow-up Comment #12, bug #41579 (project octave):
Dan,
I think we run in Matlab's idiosyncrasies here.
The example below on this file:
123;456;789
012;345;678
901;234;567
(note: with CRLF EOLs)
shows that Matlab (r017b), when reading a specified nr. of fields, advances
*behind* delimiters but *before* EOLs ater reading the last field as specified
in the format repeat count.
>> format compact
>> fid = fopen ('txtscn.txt')
fid =
3
>> C = textscan (fid, '%f %f', 1, 'delimiter', ';')
C =
1×2 cell array
{[123]} {[456]}
>> pos = ftell (fid)
pos =
8
>> txt = fread (fid, Inf, 'char=>char')'
txt =
'789
012;345;678
901;234;567
'
>> uint8 (txt)
ans =
1×31 uint8 row vector
Columns 1 through 18
55 56 57 13 10 48 49 50 59 51 52 53 59 54 55
56 13 10
Columns 19 through 31
57 48 49 59 50 51 52 59 53 54 55 13 10
>> fseek (fid, 0, 'bof')
ans =
0
>> C = textscan (fid, '%f %f %f', 1, 'delimiter', ';')
C =
1×3 cell array
{[123]} {[456]} {[789]}
>> pos = ftell (fid)
pos =
11
>> txt = fread (fid, Inf, 'char=>char')'
txt =
'
012;345;678
901;234;567
'
>> uint8 (txt)
ans =
1×28 uint8 row vector
Columns 1 through 18
13 10 48 49 50 59 51 52 53 59 54 55 56 13 10
57 48 49
Columns 19 through 28
59 50 51 52 59 53 54 55 13 10
>>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?41579>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/