Skip to content

Instantly share code, notes, and snippets.

@raydive
Created May 22, 2017 13:53
Show Gist options
  • Save raydive/9e031ad9f4d8aa48e09204c3cc884c74 to your computer and use it in GitHub Desktop.
Save raydive/9e031ad9f4d8aa48e09204c3cc884c74 to your computer and use it in GitHub Desktop.
特定のIDを持つCSVファイルの行を削除する簡単なrubyスクリプト
require 'csv'
OUTPUT_FILE = 'output.csv'
src_file, dist_file, _ = ARGV
deleted_data = CSV.read(src_file).flatten[2..-1]
CSV.open(OUTPUT_FILE, 'w') do |file|
CSV.foreach(dist_file) do |row|
file << row unless deleted_data.include?(row.first)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment