8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/squib/import/yaml_importer.rb', line 8
def import_to_dataframe(import, &block)
data = import.data.nil? ? File.read(import.file) : import.data
yml = YAML.load(data)
data = Squib::DataFrame.new
keys = yml.map { |c| c.keys}.flatten.uniq
keys.each { |k| data[k] = [] } yml.each do |card|
keys.each { |k| data[k] << card[k] }
end
unless block.nil?
data.each do |, col|
col.map! do |val|
block.yield(, val)
end
end
end
explode_quantities(data, import.explode)
end
|