From 0070341702275c22e3c809cda537378664ca71c6 Mon Sep 17 00:00:00 2001 From: takkanm Date: Wed, 27 Dec 2017 18:41:35 +0900 Subject: [PATCH] allow symbol to converters option CSV.new is allow only symbol converters option. --- lib/daru/io/io.rb | 2 +- spec/io/io_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/daru/io/io.rb b/lib/daru/io/io.rb index eba20fb70..5cf56216f 100644 --- a/lib/daru/io/io.rb +++ b/lib/daru/io/io.rb @@ -214,7 +214,7 @@ def from_csv_prepare_opts opts end def from_csv_prepare_converters(converters) - converters.flat_map do |c| + Array(converters).flat_map do |c| if ::CSV::Converters[c] ::CSV::Converters[c] elsif Daru::IO::CSV::CONVERTERS[c] diff --git a/spec/io/io_spec.rb b/spec/io/io_spec.rb index eed123f3d..7f60d2437 100644 --- a/spec/io/io_spec.rb +++ b/spec/io/io_spec.rb @@ -51,6 +51,11 @@ expect(df['Domestic'].to_a).to all be_boolean end + it "allow symbol to converters option" do + df = Daru::DataFrame.from_csv 'spec/fixtures/boolean_converter_test.csv', converters: :boolean + expect(df['Domestic'].to_a).to all be_boolean + end + it "checks for equal parsing of local CSV files and remote CSV files" do %w[matrix_test repeated_fields scientific_notation sales-funnel].each do |file| df_local = Daru::DataFrame.from_csv("spec/fixtures/#{file}.csv")