Module: TrajectPlus::Macros::Csv
- Defined in:
- lib/traject_plus/macros/csv.rb
Overview
Macros for extracting values from CSV rows
Instance Method Summary collapse
-
#column(header_or_index, options = {}) ⇒ Object
Retrieve the value of the column with the given header or index.
Instance Method Details
#column(header_or_index, options = {}) ⇒ Object
Retrieve the value of the column with the given header or index.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/traject_plus/macros/csv.rb', line 9 def column(header_or_index, = {}) lambda do |row, accumulator, _context| return if row[header_or_index].to_s.empty? result = Array(row[header_or_index].to_s) unless .empty? Deprecation.warn(self, "passing options to column is deprecated and will be removed in the next major release. Use the Traject 3 pipeline instead") end result = TrajectPlus::Extraction.(result, ) accumulator.concat(result) end end |