How to parse (extract) data from a text file?

조회 수: 3 (최근 30일)
Razvan Bataiosu
Razvan Bataiosu 2019년 3월 12일
편집: Jan 2019년 3월 12일
Hello! I have the following text file and I want to extract the data marked with red pen. The file has a lot of rows like this, but, the position of the desired data is generally the same. I have tried a few things as in the attached file, but it doesn't seem to work. Any ideas?
Thanks!
AnalyzedFile.JPG
  댓글 수: 4
Razvan Bataiosu
Razvan Bataiosu 2019년 3월 12일
The lines of interest can be identified by “CANFD” string and I would like to obtain them ideally in binary format. I have tried firstly to make a filter to take the values after the string “canfd” and then put them in cells, by each row, but I don’t know if that is the roght approach. Thank you!
Jan
Jan 2019년 3월 12일
편집: Jan 2019년 3월 12일
What exactly is "binary format?" This is not clear for the string
1 0 b 20 61 ...
Please be as sepcific as possible: What is the wanted output for the shown input?
It would be easier to write questions, if you provide the file as text and not as screenshot.

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

답변 (1개)

Jan
Jan 2019년 3월 12일
편집: Jan 2019년 3월 12일
Str = fileread(FileName);
CStr = strsplit(Str, char(10));
match = contains(CStr, 'CANFD');
Data = CStr(match);
Data contains the wanted lines now, but it is not clear to me, what you want as output.

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by