Class: Langchain::Processors::Xls
- Defined in:
- lib/langchain/processors/xls.rb
Constant Summary collapse
- EXTENSIONS =
[".xls"].freeze
- CONTENT_TYPES =
["application/vnd.ms-excel"].freeze
Instance Method Summary collapse
-
#initialize ⇒ Xls
constructor
A new instance of Xls.
-
#parse(data) ⇒ Array<Array<String>>
Parse the document and return the text.
Methods included from DependencyHelper
Constructor Details
#initialize ⇒ Xls
Returns a new instance of Xls.
9 10 11 12 |
# File 'lib/langchain/processors/xls.rb', line 9 def initialize(*) depends_on "roo" depends_on "roo-xls" end |
Instance Method Details
#parse(data) ⇒ Array<Array<String>>
Parse the document and return the text
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 |