MATLAB: Dlmread fails to import completely numeric file

dlmreadxlsread

Hi,
I use dlmread to import data form xls files and it works fine all the time except that suddenly it throws error to read one particular file of the same format. The error is :-
Error using dlmread (line 138) Mismatch between file and format string. Trouble reading 'Numeric' field from file (row number 1, field number 1) ==> ÐÏࡱá
I have checked multiple times and the file is completely numeric. I do not understand why this has to happen with only this file. I have been using this script since 3 months without issues on various occasions.
The reading code is :
files=char(fileloc(b));
dev=dlmread(files);
f_efficiency(dev,b);
where files contain the path to the selected file in string format.
I have attached the file causing the trouble. Any help is appreciated.
Best Regards, Vittal

Best Answer

dlmread() does not handle Unicode at this time. Even with UTF-8, if you have any characters outside of the range that can be represented with a single byte, then you can be sure that the file contains something that dlmread() will not consider one of the valid number-forming characters. UTF-8 with Byte Order Mark is not supported even if no other characters require multiple bytes in the file.
However, csvread() and dlmread() open the file and call textscan() to handle all of the work. textscan() is fine with reading Unicode files, as long as the proper fopen() file encoding parameter will work. (Of course if it isn't obvious that the file is Unicode then you might well not think to check.)
Related Question