how can I read spreadsheet file which is not generated by excel in Matlab

4 visualizaciones (últimos 30 días)
I have spreadsheets with file extension of ´'xls' which were generated by LABVIEW (not EXCEL). Those files can be read in EXCEL.
I tried to use "readtable" "readmatrix" "readcell" or "xlsread" to read those files in matlab. none of them work.
"Unable to open file as a workbook. Check that the file exists, read access is available, and the file is a valid spreadsheet file."
The problem can be solved by using EXCEL to open and save the file as .xls or xlsx file (exactly as the original file name) .
But I am worndering if there is an easy solution in MATLAB.
Thank you very much.
  5 comentarios
Stephen23
Stephen23 el 31 de Ag. de 2021
@JINGJING ZANG: please upload a sample file by clicking the paperclip button.

Iniciar sesión para comentar.

Respuesta aceptada

dpb
dpb el 31 de Ag. de 2021
I thought something like this might be the case -- it's a text, delimited file named as ".xls" -- Excel does have internal smarts to deal with that case, the MATLAB utilities utilize the file extension to decide how to try to open the file so the mismatch of content to file naming convention causes the failure.
>> t=readtable('5hz.xls','FileType','text');
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
>> head(t)
ans =
8×4 table
Time_ms_ Trial1_mV_ Average_mV_ Flash1
________ __________ ___________ ______
0 0.113 0.113 1
1 0.116 0.116 1
2 0.113 0.113 1
3 0.113 0.113 1
4 0.1 0.1 1
5 0.103 0.103 1
6 0.1 0.1 1
7 0.074 0.074 1
>>
works as would
Data=readmatrix('5hz.xls','FileType','text');
which gives a double array instead of table.
Or, you could rename the file to have a .txt or .dat extension.
You might want to check how you're saving these in LABVIEW; I'll bet there's a way to get the file type and name to match up.

Más respuestas (0)

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by