Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6990017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:17:26+00:00 2026-05-27T19:17:26+00:00

I have a three columns Excel file,which has the following pattern 12 A P1

  • 0

I have a three columns Excel file,which has the following pattern

12   A    P1  
23   B    P5
24   C    P2
15   D    P1
06   E    P5

The structure underlying this data set is that,
P1 contains A and D; A corresponds to 12 and D corresponds to 15
P2 contains C; C corresponds to 24
P5 contains B and E; B corresponds to 23 and E corresponds to 06

I want to represent this kind of structure in a hashed structure i.e., use P1 as a key to point to a hash, and A is used as the key for this second level hash. Is there a way to implement this in Perl?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:17:27+00:00Added an answer on May 27, 2026 at 7:17 pm

    Spreadsheet::ParseExcel can be used to parse .xls files. Below is a sample program that builds the desired data structure.

    #!/usr/bin/env perl
    
    use strict;
    use warnings;
    
    use Data::Dumper;
    use Spreadsheet::ParseExcel;
    
    my $parser    = Spreadsheet::ParseExcel->new;
    my $workbook  = $parser->parse( shift or die "Please provide a file\n" );
    my $worksheet = $workbook->worksheet(0);
    
    my %data;
    for my $row ( 0 .. $worksheet->row_range ) {
        my $value     = $worksheet->get_cell( $row, 0 )->value;
        my $key       = $worksheet->get_cell( $row, 1 )->value;
        my $super_key = $worksheet->get_cell( $row, 2 )->value;
        $data{$super_key}->{$key} = $value;
    }
    
    print Dumper \%data;
    

    Output

    $VAR1 = {
              'P5' => {
                        'E' => '06',
                        'B' => '23'
                      },
              'P2' => {
                        'C' => '24'
                      },
              'P1' => {
                        'A' => '12',
                        'D' => '15'
                      }
            };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an excel file that contain columns of data, my target is to
I have an object that reads data from an Excel file using, which takes
I have a logging table which has three columns. One column is a unique
I have an excel file that has a column that contains a number of
I have a fairly large Excel file. In this file there is a column
I have the following macro which needs to loop though an Excel-2007 table. The
I have an Excel file that I am trying to load into R using
I have two columns of integers between 1 and 16 in an excel file.
I have a data.frame in R which has been constructed off the Example 1-3
I have a Application on which i'm uploading a Excel File and displaying the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.