Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: selecting columns from a tab-separated-values file

by Tux (Monsignor)
on Jan 22, 2013 at 07:37 UTC ( #1014590=note: print w/ replies, xml ) Need Help??


in reply to selecting columns from a tab-separated-values file

Nobody suggested Text::CSV_XS yet. If your data is straightforward: no quotations, no embedded tabs or other hiding disasters, it will be slower than a plain split on TAB, but it is very versatile when dealing with the data

use Text::CSV_XS; my $csv = Text::CSV_XS->new ({ binary => 1, sep_char => "\t", auto_d +iag => 1 }); my @row = ("") x 50; $csv->bind_columns (\(@row)); while ($csv->getline ($fh)) { my @capture = @row[0, 2, 5]; }

Enjoy, Have FUN! H.Merijn


Comment on Re: selecting columns from a tab-separated-values file
Download Code
Replies are listed 'Best First'.
Re^2: selecting columns from a tab-separated-values file
by ibm1620 (Scribe) on Jan 22, 2013 at 22:39 UTC
    Good point; I have used CSV_XS to great advantage before! (However, nothing complicated about this input.)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (17)
As of 2015-07-28 14:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (256 votes), past polls