Problem using xlsread!! Unable to read XLS file - File is not in recognized format
30 次查看(过去 30 天)
显示 更早的评论
Hello,
I have inherited a script from someone which loads in an excel spread sheet in the format csv. However, I am stuck as it complains 'Unable to read XLS file /filelocation/ File is not in recognized format'.
Does anyone know what the problem is??
Here is my script:
%%OPENING SUMMARY FILE
% Uses 'parse_vindta.m'
% This produces a structure 'data', which includes fields of all
% columns of the summary file
%d = parse_VINDTA_RaTS([data_dir filesep instrument filesep instrument 'Summary.csv']);
d = parse_VINDTA(['/correctfilelocation/LucySummary.csv']);
using the function parse_VINDTA.m:
function d = parse_VINDTA(sum)
% called from VINDTA_start.m
% reads VINDTA summary files into a matlab data structure for DIC and TA
% calculations
% OJL October 2013
disp('Parsing data structure and matching profile data to carbon samples...')
global cloud_dir
[summary,text] = xlsread(sum);
It gets to this line and then shows the error message...
I am using MATLAB 2012b using a remote login to a linux server.
Any ideas?
I have tried other ideas that are on the net but with no luck..
thanks in advance, Michael
0 个评论
采纳的回答
Stephen23
2015-2-2
编辑:Stephen23
2015-2-2
Read the xlsread documentation: On Windows® systems with Microsoft Excel software, xlsread reads any file format recognized by your version of Excel. If your system does not have Excel for Windows, xlsread operates in basic import mode, and reads only XLS, XLSX, XLSM, XLTX, and XLTM files. You write that you are using a Linux server, and the documentation does not list CSV as being a supported format for Linux systems.
Also note that it is better to use fullfile to generate filepaths, rather than by string concatenation: [data_dir filesep instrument filesep...].
In any case there is a much more important question for you: why use xlsread to read a CSV file anyway? Why not use one of the CSV-reading tools, such as csvread ? This would resolve this issue completely.
Important: You need to change the variable name sum, which is used as the input argument to the function parse_VINDTA. sum is an inbuilt function in MATLAB, so shadowing its names is a really bad idea. For the same reason avoid variables names i, j, length, prod, etc.
2 个评论
Stephen23
2015-2-6
I replied to your new question with drop-in replacement code you can try.
If my response above has answered your original question, then please Accept this answer.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!