MATLAB Answers

HOW TO DELETE A LINE FROM A CREATING FILE

2 views (last 30 days)
Hello, I have a question. I am creating a .csv file in MATLAB using the commands:
T = cell2table
writetable(T,'file.csv')
. I would like to delete from this file the 2nd row only, and keeping all the other rows. How could I make it?
Thanks

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 23 Jan 2020
writetable(T(2:end, :),'file.csv')
This assumes that you want to write out the variable names but skip the first row of the matrix

  1 Comment

Ivan Michael
Ivan Michael on 23 Jan 2020
Thank you very much !!! It works

Sign in to comment.

More Answers (1)

Sindar
Sindar on 23 Jan 2020
T = cell2table;
writetable(T([1 3:end],:),'file.csv')

  0 Comments

Sign in to comment.

Sign in to answer this question.