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!