How to use textscan to read data specific out of an ASCII-File
2 views (last 30 days)
Show older comments
Leonard Haensel
on 11 May 2022
Commented: Leonard Haensel
on 12 May 2022
Hey Guys,
I need your help. I want to export the following file content from an ASCII file. However, here I am encountering difficulties so far due to the formatting of the text. I have tried different approaches. But so far in vain. Thus I turn to you.
My file has the following structure.
0.001465 SV: 4 0 1 ::AudioData::_audiobufferDecoded = D50 1.43516 1.76174 0.823262 ... 80 Samples. \n
0.001465 SV: 4 0 1 ::AudioData::_audiobufferDecoded = D50 1.43516 1.76174 0.823262 ... 80 Samples. \n ... and so on
I would like to read out exclusively the data of the audiobuffer with textscan (starts after 'D50 ' for every line).So far without success. Could you help me ?
Leo
Accepted Answer
Walter Roberson
on 11 May 2022
If each line has the same format and you are positioned after any header lines, then start the format with 8 occurrences of '%*s' to skip the first 8 columns (including the = )
If those lines are mixed in with other lines and you need to ignore the other lines then I would recommend against textscan for that kind of situation, and would suggest using regexp instead.
3 Comments
Walter Roberson
on 12 May 2022
you should be using as many %f as there are numeric fields on the line. repmat('%f', 1,80)
More Answers (0)
See Also
Categories
Find more on Text Data Preparation 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!