How to remove rows in table?
5 次查看(过去 30 天)
显示 更早的评论
Hello, I need to remove multiple rows in table... I have a table where the first column is imageFilename and there are paths to the images... i need to remove some rows by telling the program exact path... for example i have list of 60 paths which i want to remove from table... how to do this ? thanks for answers
5 个评论
回答(2 个)
Image Analyst
2023-5-8
Try this (untested):
% Nahratie tabulky LabelData
load('LabelData.mat');
% Zadanie ciest k obrazkom, ktoré chceš vymazať
pathsToDelete = {'E:\ADRIAN\BAKALARKA\DATASET\vsetko2\panasonic_fullhd_01-090-000-202109092000.jpg', 'E:\ADRIAN\BAKALARKA\DATASET\vsetko2\panasonic_fullhd_01-090-000-202109092200.jpg'};
% Vymazanie riadkov s danými cestami
numRows = height(LabelData)
rowsToDelete = false(numRows, 1);
for k = 1 : length(pathsToDelete)
thisPath = pathsToDelete{k};
% Check every row in the table for this path.
for k2 = 1 : numRows
if strcmpi(LabelData.imageFilename{k2}, thisPath)
rowsToDelete(k2) = true;
end
end
end
% Delete the rows we need to
LabelData(rowsToDelete, :) = [];
% Uloženie upravenej tabuľky
save('LabelData.mat', 'LabelData');
0 个评论
Peter Perkins
2023-6-5
You don't need loops to do this. Hard to verify that this does what you are asking for with no mat file.
pathsToDelete = {'E:\ADRIAN\BAKALARKA\DATASET\vsetko2\panasonic_fullhd_01-090-000-202109092000.jpg', 'E:\ADRIAN\BAKALARKA\DATASET\vsetko2\panasonic_fullhd_01-090-000-202109092200.jpg'};
idx = ismember(LabelData.imageFilename, pathsToDelete{i}));
LabelData(idx, :) = [];
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!