Find the missing rows and newly added rows in two different excels sheets

3 ビュー (過去 30 日間)
Santosh Biradar
Santosh Biradar 2022 年 7 月 19 日
編集済み: Santosh Biradar 2022 年 7 月 21 日
Hello
I am comparing and finding out the missing rows and newly added rows data from two different excels sheets.
I have attached 3 files.
SummaryNew.xlsx and SummaryOld.xlsx are having data. Compare those 2 excel files.
  • SummaryResult.xlsx In a result, I am expecting 2 sheets. MissingData and NewlyAddedData.
Thank you!!
I tried using
diff_rows = find(all(cellfun(@isequal, SummaryOld', SummaryNew')) == 0);
similar_rows = find(all(cellfun(@isequal, SummaryOld', SummaryNew')) == 1);
bt it is just comparing one excel whole with other.

採用された回答

Akira Agata
Akira Agata 2022 年 7 月 19 日
How about the following?
% Load the Excel files
tNew = readtable('https://jp.mathworks.com/matlabcentral/answers/uploaded_files/1069895/SummaryNew.xlsx',...
'VariableNamingRule','preserve');
tOld = readtable('https://jp.mathworks.com/matlabcentral/answers/uploaded_files/1069900/SummaryOld.xlsx',...
'VariableNamingRule','preserve');
% Newly Added data
idx = ismember(tNew, tOld, 'rows');
tNew(~idx,:)
ans = 2×4 table
PLD Status BLF File Name Time(sec) EgoSpeed(kmh) __________ ___________________ _________ _____________ {'ddd'} {'20220330_143818'} 2495.4 67.9 {'eee'} {'20220330_184617'} 3755.8 88.5
% Missing data
idx = ismember(tOld, tNew, 'rows');
tOld(~idx,:)
ans = 2×4 table
PLD Status BLF File Name Time(sec) EgoSpeed(kmh) __________ ___________________ _________ _____________ {'aaa'} {'20220330_101314'} 2101 56.1 {'bbb'} {'20220330_143818'} 2200 60
  4 件のコメント
Santosh Biradar
Santosh Biradar 2022 年 7 月 19 日
As always very Thankful :). Big Help. Thank you so much Akira Agata!!
Santosh Biradar
Santosh Biradar 2022 年 7 月 21 日
編集済み: Santosh Biradar 2022 年 7 月 21 日
I have one more step need to add in the SummaryResult.
Your responce will be very helpful.
Eg.
In the SummaryResult Excel,
if A3 having value aaa and A6 also having aaa (like the same values present in A Column only) then Entire ROWS MissingData-sheet and NewlyaddedData-sheet will be written separately to new *AAA*Sheet in the Same SummaryResult.xlsx
if A4 having value bbb and A5 also bbb (the same values present in A Column only)then entire ROWS from MissingData-sheet and NewlyaddedData-sheet will be written separately to new *BBB* sheet in the Same SummaryResult.xlsx
I have attached upated Required SummaryResult.xlxs
Please have a look for ref. Sheet AAA and BBB
Thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by