Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Two dimension array from text file

by samtregar (Abbot)
on Jul 11, 2008 at 16:44 UTC ( [id://697018]=note: print w/replies, xml ) Need Help??


in reply to Two dimension array from text file

open my $fh, "<", "file_name_here.txt" or die $!; my @data; my $header = <$fh>; while(<$fh>) { chomp; my @row = split "\t"; push @data, [ @row[0, 3, 7] ]; } close($fh) or die $!;

If your TSV is more like a CSV - if it has quoting for example - the you should use Text::CSV_XS instead of split. But if it's just raw data and raw tabs this should work fine.

-sam

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-25 05:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found