Create function for info extraction from .log file
4 views (last 30 days)
Show older comments
Dear all,
I want to write a function that enables me to extract specific information from a .log file. I am only interested in Event type, code and time. I tried now for 2 hours without any result, I would be very grateful if someone could provide some help...
6 Comments
Accepted Answer
Cedric
on 20 May 2014
Edited: Cedric
on 20 May 2014
You should be able to extract these 3 columns as follows:
content = fileread( 'myFile.txt' ) ;
data = textscan( content, '%*s%*f%s%s%f%*[^\n]', 'HeaderLines', 5 ) ;
where data is a cell array whose 3 cells, data{1} to data{3} (note the curly brackets) contain the relevant columns.
EDITED to match the 5 header lines after seeing your file.
4 Comments
Friedrich
on 21 May 2014
Its not about specifying the delimiter. Its about the formatspec you use. I think your first %*f is wrong.
More Answers (0)
See Also
Categories
Find more on Workspace Variables and MAT-Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!