I would like to create a CSV filter, so I want to read from STDIN and
write
to STDOUT.
This does not work, even though this is per the the CSV web
documentation:
require “rubygems”
require “csv”
require “nokogiri”
CSV($stdin, { :headers => true }){ |csv_in| csv_in.each { |row| p row }
}
/Users/joe/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/csv.rb:1871:in `block
(2
levels) in shift’: Unquoted fields do not allow \r or \n (line 1).
(CSV::MalformedCSVError)
from /Users/joe/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/csv.rb:1836:in
`each’
from /Users/joe/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/csv.rb:1836:in
`block
in shift’
from /Users/joe/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/csv.rb:1796:in
`loop’
from /Users/joe/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/csv.rb:1796:in
`shift’
from /Users/joe/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/csv.rb:1738:in
`each’
from tt.rb:6:in `block in ’
from /Users/joe/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/csv.rb:1048:in
`instance’
from /Users/joe/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/csv.rb:2320:in
`CSV’
from tt.rb:6:in `’
Any thought?