Syntactic Confectionery Delight | |
PerlMonks |
Re: converting a csv file to fix width textby flexvault (Monsignor) |
on Oct 31, 2015 at 15:26 UTC ( [id://1146577]=note: print w/replies, xml ) | Need Help?? |
Welcome jazzlover, The answers you received so far are all excellent. So this is my suggestion on making your life easier, if you are going to stay at the new job for some years to come. Before Perl, I used fixed width files and/or csv files, so naturally I did the same with Perl. But once I learned and re-learned the power of the Perl hash, I now keep all data files as saved hashes. (Note: I started a simple sample, but it became too complex.) This is a skeleton using your data for an example (untested). So why is this better? The format of the data can be converted (subroutine?) to whatever format is needed. It's easy to add more data fields if needed. Recently, I had to add 3 new fields for a report. No problem! Each day I have audit reports that must be in Soap, XML, PDF, MIME, docx, etc. formats, but all the raw data is saved in key/value database as saved Perl hashes. Perl is G R E A T ! Regards...Ed "Well done is better than well said." - Benjamin Franklin
In Section
Seekers of Perl Wisdom
|
|