Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How to parse a tab delimited file

by TStanley (Canon)
on Nov 25, 2004 at 17:40 UTC ( [id://410431]=note: print w/replies, xml ) Need Help??


in reply to How to parse a tab delimited file

In this case, you might want to switch to Text::xSV, which will handle it. This module also happens to have been written by one of our members.

Update: Text::CSV_XS will also do what you need.

TStanley
--------
The only thing necessary for the triumph of evil is for good men to do nothing -- Edmund Burke

Replies are listed 'Best First'.
Re^2: How to parse a tab delimited file
by existem (Sexton) on Nov 25, 2004 at 18:13 UTC

    Thanks for the help

    Sorry for being a completely stupid monk, but how do I use this?

    How can I call the new constructor setting the separator to tab (\t)?

    I have this so far but it doesn't work.

    my $csv = Text::xSV->new( filename => $csv_destination, sep => '\t', ); $csv->open_file("foo.csv"); $csv->read_header(); foreach my $field ($csv->get_fields) { if (lc($field) ne $field) { $csv->alias($field, lc($field)); } }

    Complains about using The separator '\t' is not of length 1.

    Thanks,
    Tom

      sep => '\t',

      The separator '\t' is not of length 1.

      You get rid of that error if you specify it in double quotes:

      sep => "\t",

      Cheers, Sören

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-28 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found