Just another Perl shrine | |
PerlMonks |
Re: perl print to csvby Athanasius (Archbishop) |
on Apr 21, 2015 at 03:58 UTC ( [id://1124102]=note: print w/replies, xml ) | Need Help?? |
Hello bishop2001, First, please enclose code and data in <code> ... </code> tags; see Markup in the Monastery. Second, to get the output you want, you need to work backwards and design an appropriate data structure. In this case, I think you would be better off with a hash keyed to times, with each value an inner hash of name/value pairs:
(I am assuming that, in a data entry of the form 12,1427766557, bob, the first field is the “value” and the second is the time.) Once you have this data structure, you can write the code:
Output:
Third (and notwithstanding the above code), when dealing with CSV files, you are generally well-advised to use a dedicated module, such as Text::CSV_XS. Hope that helps,
In Section
Seekers of Perl Wisdom
|
|