Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Problem with JKeenan's Hashify

by better (Acolyte)
on Apr 07, 2013 at 21:02 UTC ( #1027397=perlquestion: print w/replies, xml ) Need Help??
better has asked for the wisdom of the Perl Monks concerning the following question:

I tried to build a hash out of a an EXCEL CSV file using JKeenan's Text::CSV::Hashify, but I can't get it work.

use strict; use warnings; use Text::CSV::Hashify; my $obj = Text::CSV::Hashify->new( { file => './data/BuildHash.csv', format => 'hoh', key => 'A', }); print my $hash_ref = $obj -> fields;

The message returned is: Key ' ' already seen at ...

I tried to declare coloumn A as key. The first coloumn of the CSV file consists of fields with unique IDs. How can I declare this coloumn as key?

Replies are listed 'Best First'.
Re: Problem with JKeenan's Hashify
by NetWallah (Canon) on Apr 07, 2013 at 21:28 UTC
    The documentation for Text::CSV::Hashify clearly states:
    In particular, it is designed for the case where (a) the CSV file's first record is a list of fields...
    So - the First ROW of the CSV must contain NAMES of the columns, and these must be unique.

    Once you have these, use the name of the first column (The content of the A1 Cell) instead of "A", in your "key" specification.

                 "I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
            -- Dr. Cox, Scrubs

Re: Problem with JKeenan's Hashify
by choroba (Bishop) on Apr 07, 2013 at 21:18 UTC
    Does the first row of the file contain the names of the columns, specifying "A" for the first column?
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1027397]
Approved by igelkott
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2018-02-24 20:11 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (310 votes). Check out past polls.