Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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
Re: Problem with JKeenan's Hashify
by choroba (Abbot) 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?
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1027397]
Approved by igelkott
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2014-08-20 13:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (114 votes), past polls