thegoaltender has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to use DBD::Excel to do joins between multiple excel files. The documentation for the module isn't great and I can't find any other relevant info. Any help on this would be great.

Here are my test xls tables which I want to join on NO of each:

nobin.xls
NO,BIN
0,0000
1,0001
2,0010
3,0011
4,0100
5,0101
6,0110
7,0111
8,1000
9,1001
10,1010
11,1011
12,1100
13,1101
14,1110
15,1111

nohex.xls
NO,HEX
1,1
2,2
3,3
8,8
9,9
10,A
11,B
12,C
13,D
14,E
15,F

Thanks,
Jim

Replies are listed 'Best First'.
Re: Joins with DBD::Excel
by Anonymous Monk on Jan 02, 2004 at 18:35 UTC

    Poor man's join.

    Save each worksheet into a hash and use this idiom:

    #!/usr/bin/perl -w use strict; use Data::Dumper; my %nobin = ( 0 => '0000', 1 => '0001', 2 => '0010', 3 => '0011', 4 => '0100', 5 => '0101', 6 => '0110', 7 => '0111', 8 => '1000', 9 => '1001', 10 => '1010', 11 => '1011', 12 => '1100', 13 => '1101', 14 => '1110', 15 => '1111' ); my %nohex = ( 1 => '1', 2 => '2', 3 => '3', 8 => '8', 9 => '9', 10 => 'A', 11 => 'B', 12 => 'C', 13 => 'D', 14 => 'E', 15 => 'F' ); my %join = map { $_, [$nobin{$_}, $nohex{$_} ] } grep { exists $nohex{$_} } keys %nobin; print Dumper(\%join); __END__ $VAR1 = { '1' => [ '0001', '1' ], '2' => [ '0010', '2' ], '3' => [ '0011', '3' ], '10' => [ '1010', 'A' ], '11' => [ '1011', 'B' ], '12' => [ '1100', 'C' ], '13' => [ '1101', 'D' ], '8' => [ '1000', '8' ], '14' => [ '1110', 'E' ], '9' => [ '1001', '9' ], '15' => [ '1111', 'F' ] };
Re: Joins with DBD::Excel
by blue_cowdawg (Monsignor) on Jan 02, 2004 at 17:55 UTC

    A quick look at the DBD::Excel manpage reveals that joins (multi-table selects) are not currently supported.


    Peter L. Berghold -- Unix Professional
    Peter at Berghold dot Net
       Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice.
Re: Joins with DBD::Excel
by CountZero (Bishop) on Jan 02, 2004 at 22:46 UTC
    Warning: untried

    If your computer has an ODBC-driver to access Excel files, you might be able to use standard SQL join syntax through DBD::ODBC.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: Joins with DBD::Excel
by tilly (Archbishop) on Jan 04, 2004 at 03:20 UTC
    An alternate approach to try. Save the Excel as CSV, and then use DBD::CSV to manipulate them.
Re: Joins with DBD::Excel
by Anonymous Monk on Jan 02, 2004 at 17:42 UTC
    What have you tried so far?
      I have been able to read in the files using dbd::excel and print it out, but haven't really fidured out the command structure yet.