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

Re: Extract a column of csv

by Tux (Monsignor)
on Jun 26, 2013 at 05:57 UTC ( #1040706=note: print w/ replies, xml ) Need Help??


in reply to Extract a column of csv

# get the 4th column my @column = map { $_->[3] } @{$csv->getline_all ($fh)};

Enjoy, Have FUN! H.Merijn


Comment on Re: Extract a column of csv
Download Code
Re^2: Extract a column of csv
by Anonymous Monk on Jun 26, 2013 at 13:34 UTC
    hey i did this as per your advice
    my $in_file = 'C:\Documents and Settings\x0199665\My Documents\coll\t +gb.csv'; # open my $fh, '<', $in_file or die "could not open $in_file: $!\n"; my @column = map { $_->[4] } @{$csv->getline_all ($fh)};
    but it gives an error "can't call getline on an unidentified value

      Please start reading the documentation for Text::CSV_XS or Text::CSV. To me this error indicates that you forgot to initiate the $csv object (or that you are using a very old Text::CSV):

      use Text::CSV_XS; # or use Text::CSV; my $csv = Text::CSV_XS->new ({ binary => 1, auto_diag => 1 });

      update: can I see both the script and the data? Not much has changed for getline_all () in Text::CSV_XS since Dec 2010, when it was introduced


      Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-07-29 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls