Sha256: ec143c727841f2c0f36958e7e679cdbd1b42d7657f6c9c32315392336b06806e
Contents?: true
Size: 1.06 KB
Versions: 10
Compression:
Stored size: 1.06 KB
Contents
class Eco::API::UseCases::Default::People::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
10 entries across 10 versions & 1 rubygems