Problem using xlsread!! Unable to read XLS file - File is not in recognized format

조회 수: 48 (최근 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

채택된 답변

Stephen23
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
Michael
Michael 2015년 2월 5일
thanks for your reply, I can't seem to use csvread as I need two ouput variables (text & summary). I have created a new question here: https://uk.mathworks.com/matlabcentral/answers/175484-read-csv-file-into-two-ouput-variables-text-numbers
I have changed 'sum' -> 's'
Stephen23
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 CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by