Sha256: d75a8b62dd59e65c989f416ae0d0fff7ad5c7f9f12b074aa13f10e8c3664cd6f
Contents?: true
Size: 700 Bytes
Versions: 8
Compression:
Stored size: 700 Bytes
Contents
require 'csv' module DataSeeder module Loader class CSV include Loader attr_reader :line_number def load(io) @line_number = 0 csv = ::CSV.new(io, headers: true) csv.each do |row| begin @line_number += 1 save(row.to_hash) rescue Exception => e # TODO: Consider counting the header in the line_number count, but anyone using # config[:use_line_number_as_id] would have all there id's incremented logger.error "Exception at line #{@line_number+1}: #{e.message}" raise unless config[:continue_on_exception] end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems