Read mixed text file into array
Show older comments
I need to read this text file into array, splitting at multiple delimiters, for example at '=','space',etc. I tried 'fscanf', which works for single row, but since the rows have different structure it won't work for the whole file. Can you please help me with this?

4 Comments
Jan
on 23 Nov 2017
What is fixed and what is variable in the structure? Can e.g. the "(DEG)" change from block to block or could we ignore this detail gratefully? Is the contents of the "# column" line trivial or can it be reordered such that parsing it is obligatory?
Rafik
on 23 Nov 2017
Jan
on 25 Nov 2017
@Rafik: And what is the wanted output? The actual commands are not complicated. fopen, fgetl and fscanf with a specific format are enough. But there are still too many open details to provide reliable code, e.g. if the number of columns in the data is fixed. A guess, what you want as output, might be more confusing than useful, if it differ from your needs. Therefore I hesitate to post code as an answer.
Rafik
on 26 Nov 2017
Answers (0)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!