Why readtable is not reading all my rows, it has a limit?
60 views (last 30 days)
Show older comments
Estefany Patricia Vizuete Chacón
on 13 May 2024
Commented: Estefany Patricia Vizuete Chacón
on 13 May 2024
I'm trying to read a table with the code
datos = readtable('tmy.xlsx');
datos(4:8763,1:15)
But when I see the read data in the workspace, a matrix of 8708x27 table appears when the original file is 8763x27. I tried to put the size but it comes out:
Error using ()
Row index exceeds table dimensions.
Error in tmy_datos_tratados (line 3)
datos(4:8763,1:15)
It should be noted that in the Excel file everything is in number format and there are no empty cells.
Please help me, thank you so much.
0 Comments
Answers (1)
Steven Lord
on 13 May 2024
I believe the presence of data in P56 makes MATLAB consider rows 1 through 55 as headers. Note that detectImportOptions considers your data to start in cell A56.
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1693421/tmy.xlsx';
IO = detectImportOptions(filename)
If I update the import options to indicate the data starts at A4 (and the variable names are in the third row)
IO.DataRange = 'A4';
IO.VariableNamesRange = 'A3';
T = readtable(filename, IO);
head(T)
size(T)
See Also
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!