Class: Langchain::Processors::Xlsx
- Defined in:
- lib/langchain/processors/xlsx.rb
Constant Summary collapse
- EXTENSIONS =
[".xlsx", ".xlsm"].freeze
- CONTENT_TYPES =
["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"].freeze
Instance Method Summary collapse
-
#initialize ⇒ Xlsx
constructor
A new instance of Xlsx.
-
#parse(data) ⇒ Array<Array<String>>
Parse the document and return the text.
Methods included from DependencyHelper
Constructor Details
#initialize ⇒ Xlsx
Returns a new instance of Xlsx.
9 10 11 |
# File 'lib/langchain/processors/xlsx.rb', line 9 def initialize(*) depends_on "roo" end |
Instance Method Details
#parse(data) ⇒ Array<Array<String>>
Parse the document and return the text
16 17 18 19 20 21 22 23 |
# File 'lib/langchain/processors/xlsx.rb', line 16 def parse(data) xlsx_file = Roo::Spreadsheet.open(data) xlsx_file.each_with_pagename.flat_map do |_, sheet| sheet.map do |row| row.map { |i| i.to_s.strip } end end end |