Skip to content

Instantly share code, notes, and snippets.

@snaka
Created September 3, 2008 02:19
Show Gist options
  • Save snaka/8521 to your computer and use it in GitHub Desktop.
Save snaka/8521 to your computer and use it in GitHub Desktop.
Filter for excel csv file
# Excel cvs file filter
# usage : ruby cvs_filter.rb input.csv column_no word
#
require "csv"
col_names = nil
CSV.open(ARGV[0], 'r') do |row|
unless col_names
STDOUT << CSV.generate_line(row) + "\n"
col_names = row
end
STDOUT << CSV.generate_line(row) + "\n" if row[ARGV[1].to_i].data.include?(ARGV[2])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment