How to delete in a table a row which contains a specific word
조회 수: 38 (최근 30일)
이전 댓글 표시
Hello, I'm writing to you for this particular modification of my table that I extracted from a long .csv file using the function readtable
I have a very big table of data 56644x8 (some colums are number/coordinates, others contain words).
I'm interested to eliminate the rows which contain the word "Alignment" at the 7th column.
The more difficult step is that I would create a code that recognize words like Allignment, Allignment_test, Alignment_ecc, Alignment2 because I don't know if the input data could change in the future.
I'll appreciate all type of helps, thank you very much
Andrea
Edit: I attached a similar file to mine, hope it will be helpful
댓글 수: 0
채택된 답변
Arif Hoq
2022년 4월 13일
try with this:
A=readtable('andrea_file.csv','ReadVariableNames',false,'HeaderLines',3);
B=table2cell(A);
C=string(B)
[row col]=find(C=='Alignment_Pin');
C(row,:)=[]; % eleminating row that contains "Alignment_Pin"
C(:,[2 3])=[] % eleminating column 2 and 3
추가 답변 (1개)
Arif Hoq
2022년 4월 8일
as you did not attach your file, i have attached my own created data
A=readtable('myfile.xlsx','ReadVariableNames',false);
B=table2array(A);
C=string(B);
[row col]=find(C=='Alignment');
C(row,:)=[];
댓글 수: 3
Arif Hoq
2022년 4월 12일
is this your expectation?
A=readtable('andrea_file.csv','ReadVariableNames',false,'HeaderLines',3);
B=table2array(A);
C=string(B);
[row col]=find(C=='Alignment_Pin');
C(row,:)=[]; % eleminating row that contains "Alignment_Pin"
C(:,[2 3])=[] % eleminating column 2 and 3
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!