« Return to Thread: FasterCSV: preserving quoted strings

FasterCSV: preserving quoted strings

by Bil Kleb :: Rate this Message:

Reply to Author | View in Thread

Hi,

Google et al are failing me: How do I preserve quoted
CSV strings on output?

% cat > csv_quotes.rb << EOF
require 'rubygems'
require 'faster_csv'
require 'test/unit'

class ConversionTest < Test::Unit::TestCase
   def test_preserve_quoted_strings
     csv_data = '"string",2,0.3'
     assert_equal( csv_data, csv_data.parse_csv*',' )
   end
end
EOF

% ruby -ws csv_quotes.rb
Loaded suite csv_quotes
Started
F
Finished in 0.005189 seconds.

   1) Failure:
test_preserve_quoted_strings(ConversionTest) [csv_quotes.rb:8]:
<"\"string\",2,0.3"> expected but was
<"string,2,0.3">.

1 tests, 1 assertions, 1 failures, 0 errors

Thanks,
--
Bil Kleb
http://fun3d.larc.nasa.gov
http://twitter.com/bil_kleb

 « Return to Thread: FasterCSV: preserving quoted strings