Hello folks, I'm trying to learn perl to perform some extraction from text files. Specifically, I have files containing data tables formatted with ASCII special characters and wish to extract the headers and data into a CSV format. Example below of what the text looks like. In the data below, i'd like to locate the "text matching header" in the file, then extract the data into CSV format with the respective TRM items as headers. I'm having a hard time following examples to recreate what I need exactly. any help would be greatly appreciated.

TEXT MATCHING header here! *-------------------*--------*--------* % 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 % *----------*--------*--------*--------*

In reply to 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.