in reply to Text::CSV - parsing
Eily has already shown you how to set the options to Text::CSV to parse your data. I'd like to show an alternative: Since it's SQL*, use an SQL parser! Here, I'm using SQL::Statement:
use warnings; use strict; use SQL::Statement; use Data::Dump; my $sql = <<'END_SQL'; INSERT INTO foo VALUES (101, '1997-02-25', 'S1', 31.00, NULL, 0.00, 'this becomes two fields, + so no go', 5.11), (102, '1998-03-26', 'S1', 31.00, NULL, 0.00, 'this will remain one fie +ld', 6.11) END_SQL my $parser = SQL::Parser->new(); $parser->{RaiseError}=1; my $stmt = SQL::Statement->new($sql,$parser); dd $stmt->row_values; __END__ ( [ 101, "1997-02-25", "S1", "31.00", undef, "0.00", "this becomes two fields, so no go", 5.11, ], [ 102, "1998-03-26", "S1", "31.00", undef, "0.00", "this will remain one field", 6.11, ], )
Update: * Hmm, at least it looks more like SQL than CSV to me, although you did say it's a "MySql CSV/dump".
|
|---|