how to Read the data in excel and store it as Hash?

My Excel is in given format.

ID NAME Degree Collage

1 Teja B.Tech NIT

M.Tech IIT(the problem is in converting this line)

2 Ravi B.tech MIT

I am in a position to convert a Excel table into a key value pairs.Please help me.Thanks in advance.

use Spreadsheet::ParseExcel; $filename = shift || "Book2.xls"; $e = new Spreadsheet::ParseExcel; $eBook = $e->Parse($filename); $sheets = $eBook->{SheetCount}; $eSheet = $eBook->{Worksheet}[$sheet]; for my $row(1 .. $eSheet->{MaxRow}) { next unless (defined $eSheet->{Cells}[$row][$col]); my $master_key=$eSheet->{Cells}[$row][0]->Value; for my $col(1 .. $eSheet->{MaxCol}) { next unless (defined $eSheet->{Cells}[$row][$col]); my $key= $eSheet->{Cells}[0][$col]->Value; my $value = $eSheet->{Cells}[$row][$col]->Value; $data{$master_key}->{($key)}=$value; } } for $id(sort keys %data) { print "$id:\n "; for $role(sort keys%{$data{$id}}) { print " $role=$data{$id}{$role}\n"; } print "\n"; }

In reply to Converting Excel to Hash by ravi179

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.