Loading .log data with different number of columns

Dear all,
I would like to read the following log-file (see: attachment). I used the readtable()-function, but not all data is loaded properly. For instance, not all columns are getting loaded and some text-data is recognised as a Nan.
Do you have any suggestions on how to read the entire file?
Thanks already in advance!
Best,
Sophie

댓글 수: 3

Jon
Jon 2022년 7월 21일
The individual rows (entries) in your log file seem to contain very different kinds of information. The number of entries in each row is not even the same. Clearly this can not be put into a table where each column contains the same kind of data.
What is it you want to do with this data? If you can clearly explain the context it might point the way to how best to read it in and parse it.
My goal is to filter the data regarding the second column. I would like to obtain seperate tables containing information about MAIN, RESMAN, TRACK, COMMUN etc.
I wouldn't mind if every column does not contain the same type of information (numbers and text data). But with my current solution not everything is getting loaded so that information is already missing in the first place.
I hope that helps!
Perhaps READCELL() ?

댓글을 달려면 로그인하십시오.

답변 (1개)

Jon
Jon 2022년 7월 22일
Yes, I would also recommend readcell, so for example
logdata = readcell('Example.log','NumHeaderLines',2)
You could then make another cell array with just the entries corresponding to a specific value occuring in the third column (for some reason the second column of spaces gets read in as missing, but it doesn't really matter) this has values such as 'MAIN', 'TRACK', etc. so for example you could make a cell array of just the entries for 'MAIN' using
mainLog = logdata(strcmp('MAIN',logdata(:,3)),:)
and then turn this into a table using
T = cell2table(mainLog)
and further into a timetable using
TT = table2timetable(T)
From which hopefully you can further extract the information of interest

카테고리

질문:

2022년 7월 21일

답변:

Jon
2022년 7월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by