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

30 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Stephen23
Stephen23 am 2 Feb. 2015
Bearbeitet: Stephen23 am 2 Feb. 2015
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 Kommentare
Michael
Michael am 5 Feb. 2015
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 am 6 Feb. 2015
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by