How do I extract particular column from unformatted text in .txt file

2 Ansichten (letzte 30 Tage)
Internet Protocol, Src: 0.0.66.242 (0.0.66.242), Dst: 10.0.0.3 (10.0.0.3)
Data (22 bytes)
0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0010 00 00 00 00 00 00 ......
Time Stamp Sequence Num Packet Size Destination IP Packet Num Time Interval Protocol
0.034272 0.0.66.243 60 10.0.0.3 10 0.002262 IP
Frame 10 (60 bytes on wire, 60 bytes captured)
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: AsustekC_60:6d:80 (00:1d:60:60:6d:80)
Internet Protocol, Src: 0.0.66.243 (0.0.66.243), Dst: 10.0.0.3 (10.0.0.3)
Data (22 bytes)
0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0010 00 00 00 00 00 00 ......
Time Stamp Sequence Num Packet Size Destination IP Packet Num Time Interval Protocol
0.040435 0.0.66.244 60 10.0.0.3 11 0.006163 IP
Frame 11 (60 bytes on wire, 60 bytes captured)
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: AsustekC_60:6d:80 (00:1d:60:60:6d:80)
Internet Protocol, Src: 0.0.66.244 (0.0.66.244), Dst: 10.0.0.3 (10.0.0.3)
Data (22 bytes)
0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0010 00 00 00 00 00 00 ......
Time Stamp Sequence Num Packet Size Destination IP Packet Num Time Interval Protocol
0.043839 0.0.66.245 60 10.0.0.3 12 0.003404 IP
Frame 12 (60 bytes on wire, 60 bytes captured)
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: AsustekC_60:6d:80 (00:1d:60:60:6d:80)
Internet Protocol, Src: 0.0.66.245 (0.0.66.245), Dst: 10.0.0.3 (10.0.0.3)
Data (22 bytes)
This is my list of data from the .txt file from which I need to extract Sequence Number data which is 0.0.66.xxx. How do I do it?
  4 Kommentare
Guillaume
Guillaume am 8 Jul. 2019
Bearbeitet: Guillaume am 8 Jul. 2019
I do not know about the delimiter status
Attaching an example test file (as opposed to copy pasting into a browser which may or may not alter the actual characters of the file), would allow us to find out.
Note taht if you're using wireshark, it has options to export in text formats that are a lot easier to import into matlab than what you show (e.g. csv format).
dpb
dpb am 8 Jul. 2019
"... wireshark ... has options to export in text formats that are a lot easier to import into matlab than what you show (e.g. csv format)."
+127

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Akira Agata
Akira Agata am 9 Jul. 2019
As mentioned by many experts, it's better to save as .csv format by wireshark. But if you have to do this task from the text file for some reasons, no need to worry! :-)
% Read text file
fid = fopen('New Text Document.txt','r');
C = textscan(fid,'%s','Delimiter','\n');
C = C{1};
fclose(fid);
% Find the lines containing 'Sequence Num' and extract the next lines
idx = contains(C,'Sequence Num');
C = C([false; idx(1:end-1)]);
% Split each line with space
C = split(C);
% Extract 2nd column
seqNum = C(:,2);

Weitere Antworten (0)

Produkte


Version

R2007b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by