class DataKit::CSV::Parser
Attributes
handle[R]
headers[R]
path[R]
Public Class Methods
new(path)
click to toggle source
# File lib/data_kit/csv/parser.rb, line 10 def initialize(path) @path = path set_handle end
Public Instance Methods
each_row() { |row| ... }
click to toggle source
# File lib/data_kit/csv/parser.rb, line 15 def each_row(&block) first = true handle.rewind ::CSV.parse(handle, converters: nil) do |row| if first == true first = false @headers = row else yield row end end end
Private Instance Methods
set_handle()
click to toggle source
# File lib/data_kit/csv/parser.rb, line 31 def set_handle if path.is_a?(IO) @handle = path else @handle = File.open(path) end @handle.set_encoding( Encoding.find("BINARY"), Encoding.find("UTF-8"), {:invalid => :replace, :undef => :replace, :replace => ''} ) end