How do I extract particular column from unformatted text in .txt file
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Guillaume
2019-7-8
编辑:Guillaume
2019-7-8
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
2019-7-8
"... 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
采纳的回答
Akira Agata
2019-7-9
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);
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Export 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!