Taking Any Returned Record Set and Writing It In CVS Format to A File

I would like to be able to do the following in my controller:

@job = Job.find(:all)
write_returned_recordset_to_file(@job, "filename.txt")

And have the write_returned_recordset_to_file write the returned data
with column headers to a file. I have some idea but they are not
class independent. Any sexy suggestions?

definitely a faq item - CSV (common separated values export)

referring to this proposal:


I really like this, but this would be nice too

headers = [ "id" , "name" , ....]
exclude = [ "phone_number" , "user_id" ]
@jobs.to_csv( 'myfile.csv' , :header=> headers , :exclude_cols=>
exclue )

so I can add headers to the csv file, and also exclude certain columns

zdennis wrote: