Class: Spout::Helpers::CSVReader
- Inherits:
-
Object
- Object
- Spout::Helpers::CSVReader
- Defined in:
- lib/spout/helpers/csv_reader.rb
Overview
Reads CSVs and handles conversion of characters into UTF-8 format.
Class Method Summary collapse
Class Method Details
.read_csv(csv_file) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/spout/helpers/csv_reader.rb', line 9 def self.read_csv(csv_file) File.open(csv_file, "r:iso-8859-1:utf-8") do |file| csv = CSV.new(file, headers: true, header_converters: ->(h) { h.to_s.downcase }) while line = csv.shift # rubocop:disable Lint/AssignmentInCondition yield line.to_hash end end end |