MATLAB: How to skip last n rows while reading a csv file using readtable

csvMATLABreadtable

I have a csv file that I want to read as table in MATLAB using readtable command. However, I know that last few lines are corrupted or not reliable and I want to skip them. How can I do that using readtable. Note that a similar function is available in python's panda package for read.csv by supplying skipfooter.

Best Answer

I was overthinking. It is very simple to do actually.
T= readtable(csvfile,'PreserveVariableNames',true);
n_skip = 5;
T = T(1:end-n_skip,:);