Cannot read .xslx file
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to read in the attached .xslx file. It is a very simple file: thirteen rows, four columns, all string data. Neither readcell nor readtable works properly. With readcell I get only the first column of data. With readtable I get an error:
>> f = readtable('Agora_I_4985.xlsx')
Error using readtable
Index exceeds the number of array elements. Index must not exceed 1.
517 throw(ME)
K>>
Given the simplicity of the file, I am very surprised that this doesn't just work out of the box. What am I missing?
0 Commenti
Risposte (1)
Star Strider
il 3 Apr 2024
The R2024a version of readtable has no problems with it. Does this seem to be correct?
T1 = readtable('Agora_I_4985.xlsx', 'VariableNamingRule','preserve')
It is possible that you have a variable named ‘readtable’. To check, run this from a script or your Command Window —
which readtable -all
The result should be exactly as it is here. If ther are other entries, that is likely the problem. The solution is to re-name the variable to something that does not overshadow any MATLAB function, and makes sense in the context of the code using it.
.
5 Commenti
Star Strider
il 17 Apr 2024
Another option is to use MATLAB Online until you can get the problem with your home installation repaired. It has all the Toolboxes you have licensed, however only those. You can copy-paste the results if necessary, and copy-paste any code you write to your home installation.
To import the file to MATLAB Online, you can either use the ‘Import Data’ tab to import the file, or:
filename = websave('Agora_I_4985','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1659291/Agora_I_4985.xlsx')
T1 = readtable(filename, 'VariableNamingRule','preserve')
in your script to read it and work with it.
(I just now tested those commands in MATLAB Online to confirm that they work. They do, and the file imoprts correctly.)
.
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!