Re: Converting comma-delimited data to tab-delimited

From: Randall Perry <rgp(at)systame(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Converting comma-delimited data to tab-delimited
Date: 2002-03-31 21:25:12
Message-ID: B8CCE8E8.12444%rgp@systame.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks, I needed that.

For the benefit of anyone else who needs this feature, I've corrected some
errors in your code, and also used the latest version of the module:
Text::CSV_XS.

Here's the new code:

#!/usr/local/bin/perl -I

use Text::CSV_XS;

my $csv = Text::CSV->new;
while (<>) {
chomp;
$csv->parse($_);
print join("\t", $csv->columns), "\n";
}

Old code:

>
> use Text::CSV;
>
> my $t = Text::CSV->new;
> while (<>) {
> chomp;
> csv->parse($_);
> print join("\t", $csv->columns), "\n";
> }
>

--
Randy Perry
sysTame
Mac Consulting/Sales

phn 561.589.6449
mobile email help(at)systame(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vernon Wu 2002-03-31 21:36:47 Use Inherrtance or not, a table desing question
Previous Message Randal L. Schwartz 2002-03-31 20:41:39 Re: Converting comma-delimited data to tab-delimited