2016-09-25 14 views
0

私は内部に多くの情報を持つ大きなテキストファイルを持っています。私は「***」で始まる行だけにアクセスする必要があります。その行には17個の数字があり、それらの間にはスペースがあります。ファイルの.txtファイルから特定の行を読み取る

例は、

Msg count = 2629  
max send msg count = 34  
avg send msg count = 10.27 
imbalance send msg count = 3.31  
------------------------------ 
max recv msg count = 35  
avg recv msg count = 10.27 
imbalance recv msg count = 3.41 

***1.100020 306852 1381937 11045 5398.19 2.05 10465 5398.19 1.94 2629 34 10.27 3.31 35 10.27 3.41 0.000000 


[INFO] +++ Sat Sep 24 15:15:33 2016 
+++ (test.c:816) stat1 end 

でこれを行う方法はありますか?

答えて

0

このコードを使用してみてください:

infilename = 'nameoffile.txt'; % name of your file 
m = memmapfile(infilename); % load file to memory (and after close it) 
instrings = strsplit(char(m.Data.'),'\n','CollapseDelimiters',true).'; 

checkstr = '***'; 
% find all string (their indices) starting with checkstr 
ind = find(strncmpi(instrings,checkstr,length(checkstr))); 


if isempty(ind) 
    fprintf('\n No strings with %s',checkstr) 
else 
    % first string with string checkstr 
    instrings(ind(1)); 
end 
関連する問題