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) coding = Eco::API::Common::Session::FileManager.encoding(file) kargs = {headers: true, skip_blanks: true, encoding: coding}.merge(kargs) out = super(file, **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'