I have an output from a code in dat format. The file has the following format
Text
Text
Text
Text
3241234234
234234
23423423
34123424
1324234
iteration pressure temperature density
1 1234 312 2.12
2 1235 321 2.15
3 1234 312 2.12
4 1235 321 2.15
5 1234 312 2.12
6 1235 321 2.15
pressure temperature density
7 1234 312 2.12
8 1235 321 2.15
9 1234 312 2.12
10 1235 321 2.15
11 1234 312 2.12
warning pressure update is not linked
12 1235 321 2.15
pressure temperature density
13 1234 312 2.12
14 1235 321 2.15
15 1234 312 2.12
warning pressure update is not linked
16 1235 321 2.15
17 1234 312 2.12
18 1235 321 2.15
end of iterations
simulation time
end loop
end of code
I have written a code in which I open the dat file. Read it as a text using iostat. Then I skip the header text line and random numbers etc up to iteration line. Then read the numbers (iterations pressure temperature density). But I am stuck at few places where I need help.
The opening text lines are not constant. Sometimes these are 4 lines and sometimes five or six. Every time I have to adjust the number of lines and compile it again. Is there a way to automate this. I mean the code itself will count the text lines and skip them. Same is the next random numbers.
What I want to do is to skip the lines from start to iteration. But these are changing too. Read the numeric data only
1 1234 312 2.12 2 1235 321 2.15 3 1234 312 2.12 4 1235 321 2.15 5 1234 312 2.12 6 1235 321 2.15 7 1234 312 2.12 8 1235 321 2.15 9 1234 312 2.12 10 1235 321 2.15 11 1234 312 2.12 12 1235 321 2.15 13 1234 312 2.12 14 1235 321 2.15 15 1234 312 2.12 16 1235 321 2.15 17 1234 312 2.12 18 1235 321 2.15
and then write this data as the output file.