Read mixed text file into array

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 commentaires

Jan
Jan le 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
Rafik le 23 Nov 2017
"(DEG)" is fixed, as well as most of the strings. The VALUES of the average gas temperature, pressure etc. are changing. The contents of the '# column' line are trivial. However, the last three lines of each block are variables, and should be parsed. I've attached the txt file, in case you need it. Thank you.
Jan
Jan le 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
Rafik le 26 Nov 2017
I need to take the contents of the 'number' column and the 'X' column of each block, and put them into columns of the output matrix (one output matrix for each block). First matrix for crank=-179.9904, second matrix for crank=10. Example output:

Connectez-vous pour commenter.

Réponses (0)

Catégories

Produits

Question posée :

le 23 Nov 2017

Commenté :

le 26 Nov 2017

Community Treasure Hunt

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

Start Hunting!

Translated by