csv: data option

Close #137
This commit is contained in:
Andy Meneely
2016-03-15 17:45:39 -04:00
parent e51b99af85
commit f408b7a88f
5 changed files with 25 additions and 3 deletions
+3 -2
View File
@@ -70,9 +70,10 @@ module Squib
# @return [Hash] a hash of arrays based on columns in the table
# @api public
def csv(opts = {})
file = Args::InputFile.new(file: 'deck.csv').load!(opts).file[0]
import = Args::Import.new.load!(opts)
table = CSV.read(file, headers: true, converters: :numeric)
file = Args::InputFile.new(file: 'deck.csv').load!(opts).file[0]
data = opts.key?(:data) ? opts[:data] : File.read(file)
table = CSV.parse(data, headers: true, converters: :numeric)
check_duplicate_csv_headers(table)
hash = Hash.new
table.headers.each do |header|