octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #35852] fscanf does not read full file


From: Pascal31
Subject: [Octave-bug-tracker] [bug #35852] fscanf does not read full file
Date: Mon, 16 Apr 2012 13:31:07 +0000
User-agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.152 Safari/535.19

Follow-up Comment #12, bug #35852 (project octave):

Same issue with Octave 3.6.1 on Windows XP SP3.
It seems the issue occurs only under Windows and comes from a matter of file
"formatting":
If the file to be read is
     with Line Feed (LF) formatting only: ok
     with Carriage Return and Line Feed (CRLF) formatting: NOT ok


1°/ The function
function [z]=read_data(name)
f=fopen(name);
line1=fgets(f);
line2=fscanf(f,'%f',4);
line3=fscanf(f,'%d',2);
nx=line3(1);
ny=line3(2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
z=fscanf(f,'%f',nx*ny);
fclose(f);

% FOR DEBUG
size_z = size(z)


2°/ Data to be read
Data_CRLF.txt is the file that should be read. It has a CRLF formatting.
Data_LF.txt contains the same data but the formatting is only a LF one.
(starting from line number 4, Data_*.txt contains 40401 numbers (40401 =
201*201))





Under Octave 3.6.1 on Windows XP (and QtOctave 0.10.1)
read_data('Data_LF.txt')
size_z = 
     40401   1
it is the correct expected answer!!

read_data('Data_CRLF.txt')
size_z = 
     1099   1
it is NOT the correct expected answer !!


Other results:
Under MATLAB (6.1.0.450 (R12.1)): read_data('Data_LF.txt') gives the correct
answer
Under MATLAB(6.1.0.450 (R12.1)): read_data('Data_CRLF.txt') gives the correct
answer

Under Windows XP Octave 3.6.0: read_data('Data_CRLF.txt') gives UNCORRECT
answer
Under Windows XP Octave 3.6.0: read_data('Data_LF.txt') gives correct answer

Under Unix/linux: Octave version 3.6.0-rc1: read_data('Data_CRLF.txt') gives
the correct answer

Under Unix/linux: Octave version 3.7.0+: read_data('Data_CRLF.txt') gives the
correct answer

With cygwin, with Octave 3.6.1: read_data('Data_CRLF.txt') gives the correct
answer




(file #25658, file #25659, file #25660, file #25661)
    _______________________________________________________

Additional Item Attachment:

File name: read_data.m                    Size:0 KB
File name: Data_CRLF.txt                  Size:730 KB
File name: Data_LF.txt                    Size:720 KB
File name: fscanf_formatting_issue.zip    Size:550 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?35852>

_______________________________________________
  Message posté via/par Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]