0

Is it possible to create a CSV file right out of the command line in IRB or elsewhere with a one-time use on it. Say, I just need a CSV file with all my user's first name on it.

Can I create that without setting up any architecture?

John Topley
  • 113,588
  • 46
  • 195
  • 237
Trip
  • 26,756
  • 46
  • 158
  • 277

2 Answers2

2

Yes, use Ruby's csv library (it's part of the standard lib):

http://ruby-doc.org/stdlib/libdoc/csv/rdoc/classes/CSV/Writer.html

cam
  • 14,192
  • 1
  • 44
  • 29
  • This is amazing! I'm having so much fun. Literally covered in CSV's right now. – Trip Aug 17 '10 at 17:27
  • awesome, if `csv` ever falls short for any reason, you can check out `fastercsv` (http://fastercsv.rubyforge.org/) as well. I think it's supposed to replace `csv` in ruby 1.9 – cam Aug 17 '10 at 17:50
1

What database are you using? It seems doubtful that you'd need to use Rails at all. For example:

How to output MySQL query results in CSV format?

Community
  • 1
  • 1
jdl
  • 17,702
  • 4
  • 51
  • 54