How to read a .txt file from a certain keyword onwards
Show older comments
[13/05/15 - 15:52:49:848] RXCLIENT,2,3,1,254,-68,87,1121651473,
[13/05/15 - 15:52:49:858] TXCLIENT,2,1,1121655561,1,
[13/05/15 - 15:52:51:818] RXCLIENT,2,3,2,250,-67,90,1153331395,
[13/05/15 - 15:52:51:838] TXCLIENT,2,2,1153335490,1,
I have the above format .txt file which I want to read. I would like to read it by making RXCLIENT and TXCLIENT as starting points or keywords. In the end I would like it to be read as something like this.
A = [ RXCLIENT 2 3 1 254 -68 87 1121651473
RXCLIENT 2 3 2 250 -67 90 1153331395 ]
B = [ TXCLIENT 2 1 1121655561 1
TXCLIENT 2 2 1153335490 1 ]
Thanks
6 Comments
Walter Roberson
on 14 May 2015
Do your strcmp(D{1},'RXCLIENT') once and store it in a variable and use it for the following lines.
Yaameen
on 14 May 2015
Walter Roberson
on 14 May 2015
RXLines = strcmp(D{1}, 'RXCLIENT');
TxPacket.pkttype=D{2}(RXLines);
TxPacket.datalength=D{3}(RXLines);
TxPacket.pktnumber=D{4}(RXLines);
TxPacket.SQI=D{5}(RXLines);
TxPacket.RSSI=D{6}(RXLines);
TxPacket.LQI=D{7}(RXLines);
TxPacket.timestamp=D{8}(RXLines);
Image Analyst
on 15 May 2015
Yaameen
on 15 May 2015
Accepted Answer
More Answers (0)
Categories
Find more on String Parsing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!