Sha256: 945b3975fdbe233fb2908048b638a2ad4fb7c68fb109b2a8b30494d339ccf7d8
Contents?: true
Size: 961 Bytes
Versions: 33
Compression:
Stored size: 961 Bytes
Contents
require 'csv' module Eco class CSV < ::CSV class << self def parse(data, **kargs, &block) kargs = {headers: true, skip_blanks: true}.merge(kargs) out = super(data, **kargs, &block).reject do |row| values = row.to_hash.values values.all?(&:nil?) || values.map(&:to_s).all?(&:empty?) end Eco::CSV::Table.new(out) end def read(file, **kargs) kargs = {headers: true, skip_blanks: true}.merge(kargs) args = [file].tap do |arg| coding = Eco::API::Common::Session::FileManager.encoding(file) arg.push("rb:bom|utf-8") if coding == "bom" end out = super(*args, **kargs).reject do |row| values = row.to_hash.values values.all?(&:nil?) || values.map(&:to_s).all?(&:empty?) end Eco::CSV::Table.new(out) end end end end require_relative 'csv/table'
Version data entries
33 entries across 33 versions & 1 rubygems