Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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?

Comment on Problem with JKeenan's Hashify
Download Code
Replies are listed 'Best First'.
Re: Problem with JKeenan's Hashify
by NetWallah (Abbot) 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 (Canon) 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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2015-10-05 01:45 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (106 votes), past polls