Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: .csv file in to hash of hashes for a Berkley DB (for a hash newbie)

by space_monk (Chaplain)
on Jun 12, 2013 at 08:37 UTC ( #1038410=note: print w/ replies, xml ) Need Help??


in reply to .csv file in to hash of hashes for a Berkley DB (for a hash newbie)

I was going to comment on the reason for your problem but I've been beaten to it. However I will make one comment that I make for most questions involving CSV files:

Do not parse CSV files yourself! Use existing libraries such as Text::CSV, Text::CSV_XS, Tie::CSV_File,Tie::Handle::CSV, anything except do it yourself methods.They will automatically handle quoted fields and other CSV gotchas without you noticing most of the time. Reading CSV files line by line and using split is a poor way of doing things, only to be used in the most basic of circumstances. If someone has done all the difficult stuff for you, take advantage of their hard work.

If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)


Comment on Re: .csv file in to hash of hashes for a Berkley DB (for a hash newbie)
Re^2: .csv file in to hash of hashes for a Berkley DB (for a hash newbie)
by Doozer (Beadle) on Jun 12, 2013 at 08:43 UTC
    Thanks for all the quick responses. I have had a look at DBM::Deep and it looks like it might be what I need. I will also get some practice in with Text::CSV etc. Funny how commenting out the line which ties the hash to a DB file makes the script work (with a couple of minor tweaks). Its easy to overlook simple checks when you have been working on the same problem all day :p
Re^2: .csv file in to hash of hashes for a Berkley DB (for a hash newbie)
by Happy-the-monk (Monsignor) on Jun 12, 2013 at 08:45 UTC

    I don't think I am adding the new details for each box to the hash correctly.

    Apart from the valuable remarks of my Brothers who came to answer this before,
    your code to add the details is working well.

    So keep your efforts on fixing the data serializing aproach and when that's done, have a look at the CSV parsers.

    Cheers, Sören

    (hooked on the Perl Programming language)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2014-10-21 12:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (103 votes), past polls