Class: CsvCutter::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/csv_cutter/cli.rb

Instance Method Summary collapse

Instance Method Details

#split_by_number_rows(file_path, out_dir) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/csv_cutter/cli.rb', line 10

def split_by_number_rows(file_path, out_dir)
  symbolized_key_options = options.except('number_rows').keys.inject({}) do |new_options, key|
    new_options[key.to_sym] = options[key]
    new_options
  end

  csv = CsvCutter::Csv.new(**symbolized_key_options.merge(out_dir: out_dir))
  csv.split_by_number_rows(file_path: file_path, number_rows: options['number_rows'] || 10000)

  puts 'Successfully split csv.'
end