Sha256: 5fef593f7d8282832af2714f35bc12c78b53846b9c4941b03bcc57fa278f0523
Contents?: true
Size: 858 Bytes
Versions: 24
Compression:
Stored size: 858 Bytes
Contents
# frozen_string_literal: true require "csv" module Decidim module Admin module Import module Readers # Imports any exported CSV file to local objects. It transforms the # import data using the creator into the final target objects. class CSV < Base MIME_TYPE = "text/csv" def self.first_data_index 1 end def read_rows ::CSV.read(file, col_sep: ";").each_with_index do |row, index| yield row, index end end # Returns a StringIO def example_file(data) csv_data = ::CSV.generate(col_sep: ";") do |csv| data.each do |row| csv << row end end ::StringIO.new(csv_data) end end end end end end
Version data entries
24 entries across 24 versions & 1 rubygems