|Welcome to the Monastery|
Generating an output fileby TStanley (Canon)
|on Sep 22, 2009 at 14:59 UTC||Need Help??|
TStanley has asked for the
wisdom of the Perl Monks concerning the following question:
Greetings fellow Monks!
I have been tasked with creating a CSV file that will be imported into a new document archiving system, and after a lot of hacking, I have turned a 100MB text file into a file just under 1MB in size after removing the non-needed parts and getting it formatted. Below is a sample of what I am currently working with:
What I need to accomplish from the above is to break down the fourth field and beyond so that each one is on its own line, along with the first three lines, so the first line would look something like:
As you can see, what makes this a challenge is that each line is a different size depending upon how many reports there are to be distributed, as well as the number of people that the reports go to.
My plan is to take each line of the csv file and split it into an array with the 4th element being a reference to another array which whould contain all of the remaining lines. How would I go about creating the output csv file to look like my desired output? My code so far is below:
People sleep peaceably in their beds at night only because rough men stand ready to do violence on their behalf. -- George Orwell