Class: DataImp::Parser::Csv

Inherits:
DataImp::Parser show all
Defined in:
lib/data_imp/parser/csv.rb

Instance Attribute Summary

Attributes inherited from DataImp::Parser

#filename

Instance Method Summary collapse

Methods inherited from DataImp::Parser

find_parser, #initialize, #process

Constructor Details

This class inherits a constructor from DataImp::Parser

Instance Method Details

#optionsObject



3
4
5
# File 'lib/data_imp/parser/csv.rb', line 3

def options
  { headers: true }
end

#parse(chunk) ⇒ Object



7
8
9
# File 'lib/data_imp/parser/csv.rb', line 7

def parse chunk
  chunk.to_h
end

#process_file(&block) ⇒ Object



11
12
13
14
15
# File 'lib/data_imp/parser/csv.rb', line 11

def process_file &block
  CSV.open(filename, **options) do |csv|
    process csv, &block
  end
end