in reply to Help with CSV file parsing
DBI::quote is probably overkill. Use placeholders.
my $sql = 'INSERT INTO person VALUES (?, ?, ?)'; my $dbh = DBI->connect(YOUR CONNECTION DETAILS) or die DBI::errstr; my $sth = $dbh->prepare($sql); my $csv = 'test.csv'; open my $data, '<', $csv or die "Cannot Open File: $!\n"; while (<$data>) { chomp; $sth->execute(split /,/); }
Looks far simpler than you were trying make it. Am I missing something? And, yes, it does deal with strings with embedded quotation marks.
Oh, wait. I see what I'm missing. You don't need the quotation marks from the input data. I think you should look at Text::ParseWords.
See the Copyright notice on my home node.
"The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg
|
---|