Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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 (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 (Chancellor) 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
[kcott]: marioroy, not much to go on. Searching "slow logging" (by me) produces no results; just "slow" gives a screenful. Perhaps, "Searching large files a block at a time" which had a performance aspect and you had some imput also.
[gnosti]: Hi, Looking for a module that can add HH:MM:SS durations like 1:40, 1:00:24.13 and 12.3? I see on CPAN more modules with absolute dates. TIA

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2017-08-18 08:51 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (297 votes). Check out past polls.