Method: Daru::IO.from_excel

Defined in:
lib/daru/io/io.rb

.from_excel(path, opts = {}) ⇒ Object

Functions for loading/writing Excel files.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/daru/io/io.rb', line 41

def from_excel path, opts={}
  opts = {
    worksheet_id: 0,
    row_id: 0
  }.merge opts

  worksheet, headers = read_from_excel(path, opts)
  df = Daru::DataFrame.new({})
  headers.each_with_index do |h,i|
    col = worksheet.column(i).to_a
    col.delete_at 0
    df[h] = col
  end

  df
end