Create function to extract data from .log file

5 ビュー (過去 30 日間)
haisheng yu
haisheng yu 2017 年 9 月 28 日
コメント済み: Walter Roberson 2017 年 9 月 28 日
Dear all,
I want to write a function can extract data from log file. It like that
The number marked yellow is the number what I want to output and then used to do the calculate. I would really appreciate that if anyone can provide any help.
Thanks in advance.

採用された回答

Walter Roberson
Walter Roberson 2017 年 9 月 28 日
S = fileread('NameOfYourLogFileGoesHere.log');
value_of_interest_string = regexp('(?<=it\.it-nin\.icytot\.nrep2\.mtfail\.IMPES:\s*)\S+', 'match');
value_of_interest = str2double(value_of_interest_string);
This code does not assume that the value is an integer, just that it appears after the mtfail.IMPES: string and ends in whitespace.
  7 件のコメント
haisheng yu
haisheng yu 2017 年 9 月 28 日
Thanks a lot. It really help a lot. I also solved a way
Str = fileread('WH Generated path_09.log');
Key = 'it,it-nin,icytot,nrep2,mtfail,IMPES:';
Index = strfind(Str,Key);
Value =sscanf(Str(Index(1)+length(Key):end),'%g',1);
Walter Roberson
Walter Roberson 2017 年 9 月 28 日
Yes, sorry, I missed the S in the regexp call.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by