class LogStash::Filters::Dictionary::CsvFile

Protected Instance Methods

initialize_for_file_type() click to toggle source
# File lib/logstash/filters/dictionary/csv_file.rb, line 9
def initialize_for_file_type
  @io = StringIO.new("")
  @csv = ::CSV.new(@io)
end
read_file_into_dictionary() click to toggle source
# File lib/logstash/filters/dictionary/csv_file.rb, line 14
def read_file_into_dictionary
  # low level CSV read that tries to create as
  # few intermediate objects as possible
  # this overwrites the value at key
  IO.foreach(@dictionary_path, :mode => 'r:bom|utf-8') do |line|
    @io.string = line
    k,v = @csv.shift
    @dictionary[k] = v
  end
end