I just put together a small module for formatting table arrays as CSV file content. Generally, I needed a feature for outputting the same data either as table (using built-it theme_table() function) or as CSV.
The result is new theme_csv() function, used in exactly the same way and with the same params as theme_table(), plus two additional optional params for user-defined delimiter and enclosure:
theme_csv($header, $rows, $attributes = array(), $caption = NULL, $delimiter = ',', $enclosure = '"')
Uploaded to sandbox project here: http://drupal.org/sandbox/maciej.zgadzaj/1185828
What do you think?