in reply to Extracting fields from CSV
BED001 |137CM BUDGET BLUE B/SET |BED001 |BASE & MATTRESS | |E +a |0 |0 |39.47 |0.00 BED0015 |183CM BODY CUSHION BASE SET |BED0015 |BASE & MATTRESS + | |Ea |0 |0 |1,099.91 |0.00
BED001,137CM BUDGET BLUE B/SET,BED001,BASE & MATTRESS,,Ea,0,0,39.47,0. +00 BED0015,183CM BODY CUSHION BASE SET,BED0015,BASE & MATTRESS,,Ea,0,0,"1 +,099.91",0.00
The actual output:use strict; use Text::CSV; my $csv = Text::CSV->new( { sep_char => "|", allow_whitespace => 1 + } ); my $infile = "s.txt"; my $outfile = "s.csv"; open( my $fh, "<", $infile ); open( my $out, ">", $outfile ); while ( my $array = $csv->getline($fh) ) { local $" = ","; local $\ = "\n"; #$csv->combine(@{$array}); #my $line=$csv->string(); print $out "@{$array}"; #print $out $line; }
BED001,137CM BUDGET BLUE B/SET,BED001,BASE & MATTRESS,,Ea,0,0,39.47,0. +00 BED0015,183CM BODY CUSHION BASE SET,BED0015,BASE & MATTRESS,,Ea,0,0,1, +099.91,0.00
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Extracting fields from CSV
by Tux (Canon) on Aug 31, 2010 at 06:36 UTC | |
by suhailck (Friar) on Aug 31, 2010 at 07:05 UTC | |
|
Re^2: Extracting fields from CSV
by aquarium (Curate) on Aug 31, 2010 at 04:55 UTC |