PDA

Click to See Complete Forum and Search --> : Export To CSV


lintz
Jun 15th, 2006, 07:25 AM
Is it possible to export the results of a query to a CSV file?

If so, does anyone have an example?

john tindell
Jun 15th, 2006, 08:27 AM
You have to do it yourself, so just loop though each value and each record and write them to a file with the delimator ',' or ';' splitting them up.

lintz
Jun 15th, 2006, 09:21 PM
Thanks John, I thought that would be the solution.

visualAd
Jun 16th, 2006, 12:25 AM
In mysql you can do it with a query:

SELECT * INTO OUTFILE 'c:\path\to\csv.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
FROM table_name;

anjanesh
Jun 17th, 2006, 12:09 AM
lintz - better still - use PHP5's fputcsv (http://in.php.net/manual/en/function.fputcsv.php)