Class: Remi::Parser::Gsheet
- Inherits:
-
Remi::Parser
- Object
- Remi::Parser
- Remi::Parser::Gsheet
- Defined in:
- lib/remi/data_subjects/gsheet.rb
Instance Attribute Summary
Attributes inherited from Remi::Parser
#context, #field_symbolizer, #fields, #logger
Instance Method Summary collapse
Methods inherited from Remi::Parser
Constructor Details
This class inherits a constructor from Remi::Parser
Instance Method Details
#parse(gs_extract) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/remi/data_subjects/gsheet.rb', line 115 def parse(gs_extract) return_hash = nil gs_extract.data.each do |gs_data| if return_hash.nil? return_hash = Hash.new gs_data.values[0].each do |header| return_hash[field_symbolizer.call(header)] = [] end end headers = return_hash.keys header_idx = headers.each_with_index.to_h gs_data.values[1..-1].each do |row| headers.each do |header| idx = header_idx[header] return_hash[header] << (idx < row.size ? row[idx] : nil) end end end Remi::DataFrame.create(:daru, return_hash, order: return_hash.keys) end |