Greetings! I seek the help of fellow monks once again. This is with regard to a friend of mine, who gave me a csv containing a database dump.
Below is a sample of the dump.
Date Product Quantity Imported_From 1/2/04 Shirts 32 Australia 1/9/04 Shoes 234 Asia 2/12/04 Caps 109 UK 4/4/04 Shoes 6 Asia 4/4/04 Shirts 12 Australia 5/6/04 Shirts 398 Australia ..... ...... There are only 3 regions. One or more products can be imported from one or many regions on a sin +gle date. No single column is unique. There are many products, at the last count, it was 34.
What is needed is a summary of the report on a monthly basis. This would help in analyzing import-sales ratio for every month. (There is a similar dump for sales. That is a simpler one which does not include the 'region' field.) Output monthly report should look like:
Jan Product Asia Australia UK Total_Imported Shirts 178 12 744 934 Shoes ... ... (products whose total is zero can be omitted) Feb Product Asia Australia UK Total_Imported ....
I've worked on this for more than a couple of hours now using hashes and makeing '$date_$product' as key and quantity as its value. Using more hashes to seperate the regions. I've also tried to write to temp files and re-creating them for each month.

Is there a simple way to get the whole thing done in a single loop?
I'd appreciate any comments/thoughts from you folks.

Many thanks!
Rupesh.

In reply to (Complex)Data Manipulation by rupesh

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.