Method: ADT::Table#to_csv

Defined in:
lib/adt/table.rb

#to_csv(path = nil) ⇒ Object

Dumps all records to a CSV file. If no filename is given then CSV is output to STDOUT.

Parameters:

  • path (optional String) (defaults to: nil)

    Defaults to basename of adt file



113
114
115
116
117
118
119
120
# File 'lib/adt/table.rb', line 113

def to_csv(path = nil)
  path = File.basename(@data.path, '.adt') + '.csv' if path.nil?
  FCSV.open(path, 'w', :force_quotes => true) do |csv|
    each do |record|
      csv << record.to_a
    end
  end
end