MATLAB: Problems reading a textfile; fgetl reads *****

read datatext file

Hello,
I am trying to read text files of this format
1 1 1951 5.8
2 1 1951 0.0
3 1 1951 3.4
4 1 1951 0.0
5 1 1951 0.0
6 1 1951 0.0
... (until 2099, there are 54422 lines in each file).
Reading the files works well until for example
23 2 1997 171.7
which is read as
23 2 1997 *****
if I use fgetl, or if I continue reading the file with fscanf (e.g.
A=fscanf(fid,'%d %d %d %f',4)
nothing is read in for A(4).
If I open the file in Notepad++ it looks normal, the numbers are seperated by 1 to 3 blanks, the file has Unix line endings. Opening the file in Notepad++ and saving it solves the problem, but I have 294000 files, so that's not an option. If I skip that particular line, there is also no problem reading the other lines of the file. The problem only occurs every few thousand files.
This seems very weired. Does anybody have an idea, what the problem could be?
Thanks a lot, Doris

Best Answer

Thanks for sharing the file. I really find
23 2 1997 *****
in the specific line. No encoding problem, no text-mode tricks. There are really stars - ASCII(42). Opening it in NotePad++ and saving it does not change anything.
So I'm wondering how do you know, that it should be
23 2 1997 171.7
? Did you write this is FORTRAN with "FORMAT(F5.1)"?
Related Question