Search for string in excel file in two sheets and delete row
3 ビュー (過去 30 日間)
古いコメントを表示
Hello all!
As already in the title written i have an excel file with two sheets. Lets say excel file is called test.xls and there is sheet1 and sheet 2 in it. In every sheet there is in the row A for example A2: LOT ID and A3: BATID and also in sheet2 are these strings but at an different place like A4: LOT ID and A7: BATID
so what i want is a code that searches through both sheets looking for the MAPID and BATID and then delete the whole line.
i really dont know how to do this
this is what i tryied but it wont delete the line and also doesnt look in the second sheet:
%deleting specific lines in Excel
[~,~,rawData] = xlsread('padb2.xls');
name = 'LOT ID';
idx = find(strcmp(rawData(:,1),name),1);
if ~isempty(idx)
total = sum(cell2mat(rawData(idx,2:end)));
else
total = 0;
end
0 件のコメント
回答 (1 件)
KSSV
2018 年 9 月 10 日
[num,txt,raw] = xlsread('myfile.xlsx') ;
idx = contains(raw(:,1),'MAPID') ; % Assuming first column is the string present
raw(idx,:) = []
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!