![]() |
|
Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Converting text file to CSV formatby BrowserUk (Patriarch) |
on Mar 18, 2003 at 21:21 UTC ( #244158=note: print w/replies, xml ) | Need Help?? |
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.
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 Section
Seekers of Perl Wisdom
|
|