At 7:59 AM +0800 9/5/01, Steve Doig wrote:
>Hi Folks,
>
>I'm running a batch command in win2K: cmd> mysql < batch-file > output.txt
>In the batch file, can I specify that values are separated by commas instead
>of tabs?
No, but if you have Perl installed, you can create a file named csv.pl
that contains the following:
while (<>) # read next input line
{
s/"/""/g; # double any quotes within column values
s/\t/","/g; # put `","' between column values
s/^/"/; # add `"' before the first value
s/$/"/; # add `"' after the last value
print; # print the result
}
exit (0);
Then you can run this command:
cmd> mysql < batch-file | perl csv.pl > output.txt
and output.txt will contain CSV output. If you have a file association
set up so that .pl files get executed by Perl, you can shorten that to:
cmd> mysql < batch-file | csv.pl > output.txt
>
>Cheers,
>Steve
--
Paul DuBois, [EMAIL PROTECTED]
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php