Read file txt app designer
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Siria Fumagalli
il 17 Ott 2019
Risposto: Abhilash Padma
il 4 Nov 2019
Hello i need to read a txt file like this(i copy only a part):
Comandi:
apri bagno=1101
apri camera=1102
apri finestre=1103
---
Richiesta_aiuto:
aiuto=2101
---
Parametri:
ciao=111
after that i need to put all the words (except the header like 'Comandi' or Richiesta_aiuto'...) in a list box and the number in another listbox...
I don't know how to do that
0 Commenti
Risposta accettata
Abhilash Padma
il 4 Nov 2019
The key value pairs can be extracted from text file using Regular expression and then they can be used to put in list boxes. Check the following code which would be helpful to extract the key value pairs from the text file.
str=fileread('example.txt'); % example.txt is the file name
s=regexp(str,'(\w+\s*\w+)=(\d+)','tokens');%regexp returns a cell array which contains key value pairs.
0 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!