in reply to CSV manipulation with perl
Don't! Use Text::CSV_XS instead (or Text::CSV if you do not have a C-compiler)
use DBI; use Text::CSV_XS; my $dbh = DBI->connect (...); my $sth = $dbh->prepare ("insert into table values (?, ?, ?, ...)"); my $csv = Text::CSV_XS->new ({ binary => 1 }); open my $dta, "<", "data.csv" or die "data: $!\n"; while (my $row = $csv->getline ($dta)) { $sth->execute (@$row); } $csv->eof or $csv->error_diag; $sth->finish; $dbh->commit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: CSV manipulation with perl
by Bloodnok (Vicar) on Mar 09, 2009 at 14:17 UTC | |
|
Re^2: CSV manipulation with perl
by CountZero (Bishop) on Mar 09, 2009 at 19:41 UTC | |
by Tux (Canon) on Mar 09, 2009 at 22:46 UTC | |
|
Re^2: CSV manipulation with perl
by joec_ (Scribe) on Mar 09, 2009 at 14:27 UTC | |
by Tux (Canon) on Mar 09, 2009 at 18:14 UTC |