I have a question in Spreadsheet::ParseExcel. I have a excel sheet where there is no unique values and may have null values in any columns. I want to build a hash of hash from the excel to have my column names for my future coding/loading. At the moment my dumper of hash variable look like this
'RXX-1' => { 'RCA 1' => '', 'key' => 'HEMJJ', 'ID' => '3345', 'stem' => '', } '' => { 'RCA 1' => '', 'key' => 'HKKJ', 'ID' => '232', }
my code that does this :
for my $row(1 ..$row_max){ my $count = 1; my @data = map { my $cell = $worksheet->get_cell($row, $_); $cell ? $cell->value() : ''; } @required_cols; foreach my $col(@values){ warn $worksheet->get_cell($row,0)->value() . $col."\n"; $details->{ $worksheet->get_cell($row,0)->value() }{$col} += shift @data if defined $worksheet->get_cell($row, 1)->value(); } }
Instead of grouping them with a column I would like to group them with the row number or any unique integer if possible.
'1' => { 'code' => 'RXX-1' 'RCA 1' => '', 'key' => 'HEMJJ', 'ID' => '3345', 'stem' => '', } '2' => { 'RCA 1' => '', 'key' => 'HKKJ', 'ID' => '232, 'code' => '', ..... }
Could I use a count in the for loop? Any help/suggestions please.

In reply to Group cols with row number Spreadsheet::ParseExcel perl by Anonymous Monk

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.