Need all row data after strcmp

2 views (last 30 days)
Santosh Biradar
Santosh Biradar on 22 Jul 2022
Commented: Jan on 23 Jul 2022
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 Comments
Santosh Biradar
Santosh Biradar on 23 Jul 2022
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 on 23 Jul 2022
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.

Sign in to comment.

Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!