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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |