Overwrite single row excel information based on Unique ID in column data
2 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
Each time when I execute some functions I am storing the results in an excel file. Rows of column one contains unique ID for each subject. Whenever I execute the function new results are automatically appended into a new row. Whenever the same information is executed, I would like to overwrite rows containing unique ID information with a warning sign such as “The information is already exists would you like to overwrite them” etc. I tried this with “unique” function in matlab but no success. Any help in this regard is highly appreciated.
2 件のコメント
回答 (1 件)
Vimal Rathod
2021 年 6 月 7 日
Hi,
You could use the find and strcmp functions to find the index where the name or uniqueIndex matches.
newName = "Diana";
data = readtable('BP_Analysis.xlsx','PreserveVariableName', true);
idx = find(strcmp(data.Lastname,newName));
If find function returns empty column vector then there is no match in the available uniqueIds and you could append or else if idx is a number you will get the index.
Refer the following links to know more about find and strcmp functions.
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!