class Topographer::Importer::Input::DelimitedSpreadsheet
Public Class Methods
new(name, spreadsheet)
click to toggle source
Creates a new DelimitedSpreadsheet
input wrapper. NOTE: Since Topographer
relies on headers to map from input to output columns, you should enable header parsing in the CSV object passed in
NOTE: the CSV used to construct this object should have the :return_headers flag set or the first row of data will be lost!
@param name [String] the name of the delimited file being dealt with (e.g. My Data File 1) @param spreadsheet [CSV] the spreadsheet object to be parsed
# File lib/topographer/importer/input/delimited_spreadsheet.rb, line 15 def initialize(name, spreadsheet) @sheet = spreadsheet @name = name end
Public Instance Methods
each() { |source_data( source_identifier, to_h| ... }
click to toggle source
# File lib/topographer/importer/input/delimited_spreadsheet.rb, line 40 def each @sheet.each_with_index do |data, index| row_number = index + 2 source_identifier = "Row: #{row_number}" yield Topographer::Importer::Input::SourceData.new( source_identifier, data.to_h ) end end
get_header()
click to toggle source
Returns the headers in the CSV file, or if header parsing is not enabled, an empty array
@return [Array<String>] the headers in the file
# File lib/topographer/importer/input/delimited_spreadsheet.rb, line 23 def get_header unless @header if @sheet.headers === true @sheet.shift elsif @sheet.headers.nil? @header = [] end @header ||= @sheet.headers end @header end
input_identifier()
click to toggle source
# File lib/topographer/importer/input/delimited_spreadsheet.rb, line 36 def input_identifier @name end