필터 지우기
필터 지우기

Need all row data after strcmp

조회 수: 3 (최근 30일)
Santosh Biradar
Santosh Biradar 2022년 7월 22일
댓글: Jan 2022년 7월 23일
try
in = 'AAA';
p = strcmp(in,raw);
if p >= 0
xlswrite('SummaryResult.xlsx',raw1(p),'AAA','A2')
else
0;
end
end
Once I will compare
I want all the row data where AAA is presnt in those column.
Please let me know for brief.
  댓글 수: 5
Santosh Biradar
Santosh Biradar 2022년 7월 23일
Hello @Jan
Here is 1st approach code 1: %%Here I want to find out 'aaa' from sheet->'MissingData', & later list out all Row data present on aaa column new sheet in same excel. This is done with writetable and readtable.
idx = ismember(tOld, tNew, 'rows'); %excels compared
writetable(tOld(~idx,:), 'SummaryResult.xlsx', 'Sheet', 'MissingData','Range','A2') %new sheet prepared with missing data
%%for finding 'aaa' i prepared dummy excel and compared with MissingData sheet
name = {'aaa'};
T = table(name);
writetable(T,'DummyTable.xlsx','sheet','temp');
B = readtable('DummyTable.xlsx','sheet','temp');
B = B(1:end,1:1);
A1 = readtable('SummaryResult.xlsx','sheet','MissingData'); %excels compared
A = A1(1:end,1:1);
idx = ismember(A, B, 'rows');
writeable(A(~idx,:),'SummaryResult.xlsx', 'Sheet', '724_MapDiff','Range','A2')
Second approach Code: Here the purpose is same but i used strcmp.
idx = ismember(tOld, tNew, 'rows'); %excels compared
writetable(tOld(~idx,:), 'SummaryResult.xlsx', 'Sheet', 'MissingData','Range','A2') %new sheet prepared with missing data
[num,txt,raw] = xlsread('SummaryResult.xlsx','NewlyAddedData');
in = 'aaa';
p = strcmp(in,raw(:,1)); % as 'aaa' is present in A column so.
if (p(:))
xlswrite('SummaryResult.xlsx',raw(p),'aaa','A2')
else
%do nothing
end
Please let me know for brief. I also have attached expected SummaryResult.xlsx. Pls look sheet3 and Sheet4.
Thank you
Jan
Jan 2022년 7월 23일
I asked you, what the purpose of "if p >= 0" is. You did not answer this, but post the new line: "if (p(:))". Agaion the purpose is unclear. Do you mean:
if any(p(:))
Do you see, that your can format code in the forum? Please use the corresponding tools.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by