Sha256: 194fc041d24d8adfe8dfa8e69040f05b45c7f37a315120c2a5323a2b7e2d74ac

Contents?: true

Size: 614 Bytes

Versions: 21

Compression:

Stored size: 614 Bytes

Contents

#!/usr/bin/env ruby
require 'team_effort'

def do_cmd(cmd)
  `#{cmd}`
  raise "'#{cmd}' failed with #{status}" if !$?.success?
end

csv_file = ARGV[0]
lines = ARGV[1]
csv_file_name = File.basename(csv_file)
system "ghead -n 1 #{csv_file} > #{csv_file_name}_header"
system "gtail -n +2 #{csv_file} | gsplit -l #{lines} -a 3 - #{csv_file_name}_"
files = Dir.entries(".").reject { |f| f =~ %r{^(\.\.?|log)$} }
TeamEffort.work(files, 1) do |file|
  tmp_file = "tmp_#{file}"
  do_cmd "gcat #{csv_file_name}_header #{file} >> #{tmp_file}"
  do_cmd "mv #{tmp_file} #{file}"
end
do_cmd "rm #{csv_file_name}_header"
puts ""

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
advance-0.3.10 bin/split_csv.rb
advance-0.3.9 bin/split_csv.rb
advance-0.3.8 bin/split_csv.rb
advance-0.3.7 bin/split_csv.rb
advance-0.3.4 bin/split_csv.rb
advance-0.3.3 bin/split_csv.rb
advance-0.3.2 bin/split_csv.rb
advance-0.3.1 bin/split_csv.rb
advance-0.3.0 bin/split_csv.rb
advance-0.2.1 bin/split_csv.rb
advance-0.2.0 bin/split_csv.rb
advance-0.1.13 bin/split_csv.rb
advance-0.1.12 bin/split_csv.rb
advance-0.1.9 bin/split_csv.rb
advance-0.1.8 bin/split_csv.rb
advance-0.1.7 bin/split_csv.rb
advance-0.1.6 bin/split_csv.rb
advance-0.1.5 bin/split_csv.rb
advance-0.1.4 bin/split_csv.rb
advance-0.1.3 bin/split_csv.rb