#!/usr/bin/env ruby while STDIN.gets tokens = $_.chomp.encode("UTF-8", {:invalid => :replace, :undef => :replace}).split(";") begin #puts "\"#{tokens[0]}\",\"#{tokens.last}\"" if tokens[3] puts "#{tokens[0]},#{tokens.last}" if tokens[3] #puts tokens.last if tokens[3] rescue end end