Method: FlatFile::CSV.from_stream
- Defined in:
- lib/flat_file/csv.rb
.from_stream(data) ⇒ Array<Hash>
Read a CSV stream and return its contents as an array of hashes.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/flat_file/csv.rb', line 33 def self.from_stream(data) rows = [] begin ::CSV.new(data, headers: true).each do |row| rows.append(row) end return rows rescue StandardError => e # if defined?(Rails) # Rails.logger.error({ # message: "Error reading CSV data", # error: e, # }) # end return rows end end |