Skip to content

Instantly share code, notes, and snippets.

@rohitn
Created May 18, 2012 18:55
Show Gist options
  • Save rohitn/2727033 to your computer and use it in GitHub Desktop.
Save rohitn/2727033 to your computer and use it in GitHub Desktop.
Use FasterCSV for Dataset#to_csv
module Sequel
class Dataset
def to_csv(file_name, mode, opts = {})
n = naked
cols = n.columns
FasterCSV.open(file_name, mode, opts) do |csv|
csv << cols
n.each{|r| csv << cols.map{|c| r[c]}}
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment