How to search particular word for ex. 'Home' in csv file and print it.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Akash Lonkar
am 1 Mär. 2020
Kommentiert: Akash Lonkar
am 2 Mär. 2020
I want to search particular string for ex. 'Home' in csv file, if it is there then print that whole row containing 5 column on output window.
Please help me with this
Thanks in advance
0 Kommentare
Akzeptierte Antwort
dpb
am 1 Mär. 2020
Is no builtin text search routine for files; using the system grep utility or like is a very good way to do this if is just to search for a given string in file..
In Matlab, simplest is to read the full file into memory as cellstr() array and then do the string search.
txt=textread('yourfile.txt','%s','delimiter','\n');
matchstr='Home';
ix=contains(txt,matchstr);
disp(txt{ix})
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu File Operations 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!