Class: Fluent::Plugin::CsvWithHeaderParser

Inherits:
Parser
  • Object
show all
Defined in:
lib/fluent/plugin/parser_csv_with_header.rb

Instance Method Summary collapse

Instance Method Details

#parse(text, &block) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fluent/plugin/parser_csv_with_header.rb', line 28

def parse(text, &block)
  values = CSV.parse_line(text, col_sep: @delimiter)
  if @keys.empty?
    @keys = values
  elsif (@keys - values).empty?
    return
  else
    r = Hash[@keys.zip(values)]
    time, record = convert_values(parse_time(r), r)
    yield time, record
  end
end