MATLAB: Skip Last Line of .csv File

csvtextscan

I'm reading in a .csv file with a large header and one undesired line at the very end of the file. I'm using textscan and the parameter 'headerlines' to successfully skip the header, but I can't figure out how to skip the last line of the file.
I'm having no problems with skipping lines at the beginning of the file, only with skipping the last line. Could anyone offer a detailed description of how to skip the last line of the file?

Best Answer

You cannot ignore the trailing line using textscan(). I recommend to import all data and delete the last row afterwards. I assume something like this will help:
C = textscan(...);
for iC = 1:length(C)
C{iC} = C{iC}(1:end, :);
end