This seems to be quite easy. From looking at your data, you probably don't even need to distinguish between headers and data, but only to remove lines with dashes, lines of "=" signs and blank signs, to do a bit of cleanup, and then split on /%\s*/ pattern. For example this Perl two-liner under the shell command line:
$ echo '*-------------------*--------*--------* % Trm 4 % Trm 5 % % % *----------*--------* % % % Trm7 % Trm % Trm9 % TrmY0 % % % % % % *==========*========*========*========* % 0.021 % -0.X % 0.0 % 5.X % % -0.063 % -0.4 % 0.0 % 5.6 % % 0.008 % -0.X % 0.0 % 5.8 % % -0.065 % -0.5 % 0.0 % 5.9 % % 0.009 % -0.X % 0.0 % 6.0 % % -0.066 % -0.4 % 0.0 % 6.Y % % 0.007 % -0.X % 0.0 % 6.Y % % -0.065 % -0.5 % 0.0 % 6.X % % 0.006 % -0.X % 0.0 % 6.X % % -0.065 % -0.5 % 0.0 % 6.3 % % 0.005 % -0.3 % 0.0 % 6.3 % % -0.069 % -0.5 % 0.0 % 6.3 % % 0.003 % -0.X % 0.0 % 6.4 % % -0.068 % -0.4 % 0.0 % 6.4 % % 0.003 % -0.3 % 0.0 % 6.4 % % -0.07Y % -0.5 % 0.0 % 6.4 % % 0.00X % -0.X % 0.0 % 6.4 % % -0.07Y % -0.5 % 0.0 % 6.4 % % 0.00Y % -0.3 % 0.0 % 6.4 % % -0.07Y % -0.4 % 0.0 % 6.5 % % 0.003 % -0.X % 0.0 % 6.5 % % -0.07Y % -0.4 % 0.0 % 6.5 % % 0.00X % -0.X % 0.0 % 6.5 % % -0.07Y % -0.5 % 0.0 % 6.5 % % 0.00Y % -0.3 % 0.0 % 6.5 % *----------*--------*--------*--------*' | perl -nE ' next if /----/ or /\={3}/ or /% % % % %/ +; s/^%\s+//; s/\s+//g; say join ",", split /%\s*/, $_; ' Trm4,Trm5 Trm7,Trm,Trm9,TrmY0 0.021,-0.X,0.0,5.X -0.063,-0.4,0.0,5.6 0.008,-0.X,0.0,5.8 -0.065,-0.5,0.0,5.9 0.009,-0.X,0.0,6.0 -0.066,-0.4,0.0,6.Y 0.007,-0.X,0.0,6.Y -0.065,-0.5,0.0,6.X 0.006,-0.X,0.0,6.X -0.065,-0.5,0.0,6.3 0.005,-0.3,0.0,6.3 -0.069,-0.5,0.0,6.3 0.003,-0.X,0.0,6.4 -0.068,-0.4,0.0,6.4 0.003,-0.3,0.0,6.4 -0.07Y,-0.5,0.0,6.4 0.00X,-0.X,0.0,6.4 -0.07Y,-0.5,0.0,6.4 0.00Y,-0.3,0.0,6.4 -0.07Y,-0.4,0.0,6.5 0.003,-0.X,0.0,6.5 -0.07Y,-0.4,0.0,6.5 0.00X,-0.X,0.0,6.5 -0.07Y,-0.5,0.0,6.5 0.00Y,-0.3,0.0,6.5
should give you more or less what you want.

In reply to Re: Sorting through a file with multiple tables and extracting data by Laurent_R
in thread Sorting through a file with multiple tables and extracting data by thrixim

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.