Using perl's -n and -l switches on the shebang line of a short script in conjuction with a few global variables and a BEGIN block make this kind of processing the epitomy of the perl 'backronym' Practical Extraction & Reporting Language. Real bread&butter stuff.

You will probably need to strengthen the regexes to suit your data, and you may need to adjust the format used for the printf somewhat, but this should get you some of the way there.

The only slightly trick part if the $headerProcessed var and the use of eof which isn't very well described.

Usage: yourscriptname files* > unified.log

If your on a platform that expands wildcard arguments on the command line, the comment out the first line of the BEGIN block. The second line will list the expanded wilcards to STDERR which may or may not be useful in use.

#! perl -nlw use strict; use vars qw[$format $headerProcessed $author $MRnumber $releaseNo $fea +tureNo $featureName $filename $date]; BEGIN{ @ARGV = map{ glob } @ARGV; print STDERR "Processing files @ARGV"; $format = '%-25s ' x 9 . $/; $headerProcessed = 0; printf $format, 'File Name,', 'Author(Core ID),', 'Date (MM/DD/YEAR),', 'Release No.,', 'MR No.,', 'Feature No.,', 'Feature Name,', 'Paragrah No.,', 'Requirement No.'; } $headerProcessed = 0 if eof; unless ( $headerProcessed ) { $author = $1 . ',' if m[^Author \(Core ID\) : (.*$)]; $MRnumber = $1 . ',' if m[^MR Number : (.*$)]; $releaseNo = $1 . ',' if m[^Release Number : (.*$)]; ($featureNo, $featureName) = ($1 . ',', $2 . ',') if m[^Feature : (.*?) : (. +*$)]; $filename = $1 . ',' if m[^File Name : (.*$)]; $date = $1 . ',' if m[^Modification Date : (.*$)]; $headerProcessed = 1 if m[^Paragraph Number Requiremen +t Number Last Modified Release$]; } else { printf $format, $filename, $author, $date, $releaseNo, $MRnumber, $featureNo, +$featureName, (split/\s+/)[0,1]; } __END__ C:\test>244122 244122.dat? Processing files 244122.dat1 244122.dat2 File Name, Author(Core ID), Date (MM/DD/YEAR), + Release No., MR No., Feature N +o., Feature Name, Paragrah No., +Requirement No. cpsfs_sdu_setup.fm, az1287, 10/24/2001, + 16.1, sc018498.14, na, + Add IP, SDUSETUP-SDU-249 +CPSFS-SDUSETUP-224 cpsfs_sdu_setup.fm, bz1287, 10/24/2001, + 16.1, sc018498.14, na, + Add IP, SDUSETUP-SDU-249 +CPSFS-SDUSETUP-224 C:\test>

Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.

In reply to Re: Converting text file to CSV format by BrowserUk
in thread Converting text file to CSV format by pelp

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.