code that would identify the identical rows
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Alberto Acri
am 18 Nov. 2022
Kommentiert: Alberto Acri
am 18 Nov. 2022
Hello! I have a text file (.txt) consisting of 'M' rows and 3 columns. I would like to write a code that allows to identify the identical rows (the highlighted rows) and keep only one copy, of each repeated row, within the text file.
As a result, if a row repeats one or more times, I have to recreate the text file (.txt):
- keeping the lines that do not repeat
- bringing back only once the lines that are repeated
For example:
I thank you if anyone can help me!
0 Kommentare
Akzeptierte Antwort
Arif Hoq
am 18 Nov. 2022
a=table2array(readtable("file.txt"));
output=unique(a,'rows','stable')
3 Kommentare
Arif Hoq
am 18 Nov. 2022
a=table2array(readtable("file.txt"));
[output,ia,ic]=unique(a,'rows','stable')
index vector ic represents the repetition. Here indexes 1,7,13 are the duplicate rows as well 4,10.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!