Method: Langchain::Processors::Xls#parse

Defined in:
lib/langchain/processors/xls.rb

#parse(data) ⇒ Array<Array<String>>

Parse the document and return the text

Parameters:

  • data (File)

Returns:

  • (Array<Array<String>>)

    Array of rows, each row is an array of cells


17
18
19
20
21
22
23
24
# File 'lib/langchain/processors/xls.rb', line 17

def parse(data)
  xls_file = Roo::Spreadsheet.open(data)
  xls_file.each_with_pagename.flat_map do |_, sheet|
    sheet.map do |row|
      row.map { |i| i.to_s.strip }
    end
  end
end