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

52 次查看(过去 30 天)
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.

采纳的回答

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

更多回答(1 个)

KALYAN ACHARJYA
KALYAN ACHARJYA 2021-2-16
编辑:KALYAN ACHARJYA 2021-2-16
This way?
data_table=readtable('filename');
%want to remove n rows from last
n=;...?
data=data_table(1:end-n,:)
  4 个评论

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by