Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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

by Tux (Abbot)
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

Replies are listed 'Best First'.
Re^2: selecting columns from a tab-separated-values file
by ibm1620 (Monk) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1014590]
[Eily]: wow, don't say that in Nancy LanX :P
[erix]: maybe you used the car routes, I used the walking routes
[Eily]: there's a rivalry between the two cities, so defining one in terms of the other might not be well received
[Eily]: erix well I did click on the walking icon
LanX giggles!
[LanX]: Eily I'm duing this constantly with people from rival cities ...MUCHO fun!
[Eily]: The best example of that is the TGV, they couldn't decide who would get it so it's in the middle of nowhere halfway between the two
[LanX]: Eily: that rings a bell
[erix]: interesting difference, I suppose they use different data/routes (and shorter seems better, no?)
[LanX]: Montabaur station

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2017-12-13 15:24 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (369 votes). Check out past polls.