Created
May 18, 2012 18:55
-
-
Save rohitn/2727033 to your computer and use it in GitHub Desktop.
Use FasterCSV for Dataset#to_csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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