when i try to read a .xls file it gives the following error. I do not see any difference in line 251. Length of the file is just about 2000 rows and 13 columns.
Error using xlsread (line 251) XLSREAD unable to read sheet '2017'. File contains unexpected record length. Try saving as Excel 98.

댓글 수: 9

Guillaume
Guillaume 2018년 6월 15일
Which version of excel have you got installed? And which function are you using to read the file, xlsread or readtable? Finally, which version of matlab?
Sounds like your excel file is corrupted
Excel version 15.34. I used xlsread. MATLAB_R2016a
Walter Roberson
Walter Roberson 2018년 6월 15일
Sounds like a corrupted file to me, but you could try using readtable() with it.
Guillaume
Guillaume 2018년 6월 15일
Does the file open fine in excel? Can you attach it to your question by any chance?
it is originally a .csv file. I saved it in .xls as it is more familiar to me. I am attaching both files.
Guillaume
Guillaume 2018년 6월 15일
I get no error when opening your file with xlsread. However, I'm using a newer version of excel and matlab (Office365 and R2018a respectively). I'm fairly certain the error you see comes from excel.
It's a rather puzzling error since it complains about a sheet called '2017' which does not exists in your workbook. Which exact command are you using?
Why don't read the csv file directly in matlab?
Walter Roberson
Walter Roberson 2018년 6월 15일
I suggest using readtable() of the .xls, possibly using the 'sheet' option since you have two sheets.
I am not clear what either Guillaume and Walter say how to proceed with csv or readtable.
T1 = readtable('fire_archive_M6_12734_T.xls', 'Sheet', 1);
T2 = readtable('fire_archive_M6_12734_T.xls', 'Sheet', 2);

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

태그

Community Treasure Hunt

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

Start Hunting!

Translated by