Added 'sep' parameter to csv DSL method to define the column seperator of the file

dev
Mirko Kugelmeier 2016-03-23 15:13:28 +01:00
parent dad2ab5ba9
commit 5eee51f38b
1 changed files with 2 additions and 1 deletions

View File

@ -34,7 +34,8 @@ module Squib
import = Args::Import.new.load!(opts) import = Args::Import.new.load!(opts)
file = Args::InputFile.new(file: 'deck.csv').load!(opts).file[0] file = Args::InputFile.new(file: 'deck.csv').load!(opts).file[0]
data = opts.key?(:data) ? opts[:data] : File.read(file) data = opts.key?(:data) ? opts[:data] : File.read(file)
table = CSV.parse(data, headers: true, converters: :numeric) sep = opts.key?(:sep) ? opts[:sep] : ','
table = CSV.parse(data, headers: true, converters: :numeric, col_sep: sep)
check_duplicate_csv_headers(table) check_duplicate_csv_headers(table)
hash = Hash.new hash = Hash.new
table.headers.each do |header| table.headers.each do |header|