Class: Extract
- Inherits:
-
Object
- Object
- Extract
- Defined in:
- lib/setl_tool/extract.rb
Overview
Extract data into a in-memory table
Instance Attribute Summary collapse
-
#table ⇒ Object
readonly
In-memory table.
Instance Method Summary collapse
-
#data ⇒ Object
Extract data from @src_type.
-
#initialize(src_type, headers, src_path) ⇒ Extract
constructor
Currently src_type only ‘csv’ is supported Headers true if source has column names in first row src_path is an absolute path to the csv file.
Constructor Details
#initialize(src_type, headers, src_path) ⇒ Extract
Currently src_type only ‘csv’ is supported Headers true if source has column names in first row src_path is an absolute path to the csv file
27 28 29 30 31 32 33 |
# File 'lib/setl_tool/extract.rb', line 27 def initialize(src_type, headers, src_path) @src_type = src_type @headers = headers @src_path = src_path end |
Instance Attribute Details
#table ⇒ Object (readonly)
In-memory table
22 23 24 |
# File 'lib/setl_tool/extract.rb', line 22 def table @table end |
Instance Method Details
#data ⇒ Object
Extract data from @src_type
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/setl_tool/extract.rb', line 36 def data case @src_type when "csv" @table = CSV.read(@src_path, :headers => @headers) # TODO FIX headers #@col_headers = @table.headers #if @headers # @table.by_col! #@table.delete(0) #end else puts "xlsl" end end |