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:

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/
99ea153cc378f7f1/ba010c2c547d7637?lnk=gst&q=%5BFAQ%
5D&rnum=2#ba010c2c547d7637

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
easily

zdennis wrote: