• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Matlab Help: How to load this into an array?

uCsDNerd

Senior member
Hi All,
I have a large text file containing network packet sniffer data (example below). I'd like to load this file into matlab as an array so that I may filter the file for lines that contain a certain IP address and packet ID number.

#### Original File Data (altered IPs) ####
0 1056650630.099362 xxx.xx.220.40 xxx.xx.129.134 6 22 3221 53489 1500 0.113983
0 1056650630.099367 xxx.xx.220.40 xxx.xx.129.134 6 22 3221 53490 1500 0.114050
0 1056650630.110324 xxx.xx.220.40 xxx.xx.129.134 6 22 3221 53491 1500 0.103093
0 1056650630.110329 xxx.xx.220.40 xxx.xx.129.134 6 22 3221 53492 1500 0.103160
0 1056650630.110333 xxx.xx.220.40 xxx.xx.129.134 6 22 3221 53493 1500 0.103156
0 1056650630.110337 xxx.xx.220.40 xxx.xx.129.134 6 22 3221 53494 1500 0.103225
0 1056650630.110340 xxx.xx.220.40 xxx.xx.129.134 6 22 3221 53495 1500 0.103222
0 1056650630.193058 xxx.xx.220.40 xxx.xx.129.134 6 22 3221 53496 1500 0.021064
0 1056650630.193065 xxx.xx.220.40 xxx.xx.129.134 6 22 3221 53497 1500 0.021057



The problem that I am having is that when loading the file into matlab using the commands:

A = load('network.log');
B = num2str(B);

#### Data after being loaded into matlab ####
0 1056650591.5247 xxx.xx xxx.xx 6 214 22 6188 120 0.328
0 1056650591.525 xxx.xx xxx.xx 6 22 214 5513 88 0.104029
0 1056650591.629 xxx.xx xxx.xx 6 214 22 6129 120 0.000191
0 1056650591.6292 xxx.xx xxx.xx 6 22 214 55133 88 0.13156
0 1056650591.7958 xxx.xx xxx.xx 6 214 22 6132 120 0.000122
0 1056650591.7959 xxx.xx xxx.xx 6 22 214 55334 88 0.163322
0 1056650591.9622 xxx.xx xxx.xx 6 214 22 61299 120 0.000123
0 1056650591.9623 xxx.xx xxx.xx 6 22 214 5510 88 0.197155
0 1056650593.8982 xxx.xx xxx.xx 6 214 22 61321 120 0.000174
0 1056650593.8984 xxx.xx xxx.xx 6 22 214 5546 88 0.163508


Not only does it only round off my timestamps (column 2), it also truncates my IP addresses!!
Can someone please tell me how can I get around this?

Thank you!

 
I don't know if this will work, but you could try entering 'format long' (without the quotes) before you load the data in from the file.
 
It's possible that it's only displaying in way you don't expect, but it still has the info in place. I suppose you could always use fscanf or some cousin of it (try "help fscanf").
 
Back
Top