[prev in list] [next in list] [prev in thread] [next in thread]
List: postgresql-general
Subject: Re: [GENERAL] Converting comma-delimited data to tab-delimited
From: Randall Perry <rgp () systame ! com>
Date: 2002-03-31 22:43:56
[Download RAW message or body]
Sorry, that last code didn't work. This does:
use Text::CSV_XS;
my $csv = Text::CSV_XS->new();
while (<>) {
$csv->parse($_);
print join("\t", $csv->fields) . "\n";
}
> 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@systame.com
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic