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

Re^7: Read CSV with column mapping

by Tux (Abbot)
on Dec 17, 2018 at 07:59 UTC ( #1227339=note: print w/replies, xml ) Need Help??


in reply to Re^6: Read CSV with column mapping
in thread Read CSV with column mapping

Two alternatives:

use 5.14.1; use warnings; use Data::Peek; use Text::CSV_XS "csv"; my %hash; csv (in => "pm1227312.csv", out => undef, on_in => sub { my ($key, $value) = @{$_[1]}; $key && $key !~ m/^\s*(?:#|$)/ and $hash{$key} = $value; }); DDumper \%hash; %hash = map { @$_ } @{csv (in => "pm1227312.csv", filter => { 0 => sub + { !m/^\s*(?:#|$)/ }})}; DDumper \%hash;

Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^8: Read CSV with column mapping
by BillKSmith (Prior) on Jun 21, 2019 at 12:36 UTC
    At least read the documentation for Text::CSV. Even if you do not use the module, its discussion of special cases should be useful. Please ignore this post. I am not sure how I replied to such an old thread.
    Bill

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2019-11-21 21:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (105 votes). Check out past polls.

    Notices?