in reply to Re: save the result of sql query in csv file
in thread save the result of sql query in csv file
To avoid problems with commas and quoting, use Text::CSV_XS or Text::xSV written by tilly; here it is an example using the first module:
use Text::CSV_XS; $csv = Text::CSV_XS->new({ 'quote_char' => '"', 'escape_char' => '"', 'sep_char' => ',', 'binary' => 0, 'eol' => "\r\n" }); while (my @row = $sth->fetchrow_array) { if ($csv->combine(@row)) { print $csv->string; } else { my $err = $csv->error_input; print "combine() failed on argument: ", $err, "\r\n"; } }
Ciao, Valerio
|
|---|