Sha256: 63ad85456f98abbabd6fc3949d10f3b5659f2be5a6fad1ea4c545126bfef0119
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
class Eco::API::UseCases::Default::Utils::SplitCsv < Eco::API::Common::Loaders::UseCase require_relative 'cli/split_csv_cli' MAX_ROWS = 15_000 name "split-csv" type :other def main(*_args) if simulate? count = Eco::CSV.count(input_file, start_at: start_at) log(:info) { "CSV '#{input_file}' has #{count} rows." } else Eco::CSV.split( input_file, max_rows: max_rows, start_at: start_at, &filter ).each do |file| log(:info) { "Generated file '#{file}'" } end end end private def filter nil end def input_file options.dig(:source, :file) end def max_rows max_rows_options || self.class::MAX_ROWS end def max_rows_options return nil unless (num = options.dig(:output, :file, :max_rows)) num = num.to_i num = nil if num.zero? num end def start_at return nil unless (num = options.dig(:output, :file, :start_at)) num = num.to_i num = nil if num.zero? num end end
Version data entries
3 entries across 3 versions & 1 rubygems