Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Alexander Logvinov
RE: Can't parse csv file [ reply ]  
2007-12-15 01:41
Ok, thanks. I use iconv library to convert data to UTF-8, but after parsing. :) Thanks for replies! I'll try it again.

By: James Gray
RE: Can't parse csv file [ reply ]  
2007-12-15 01:30
Stefan has it right.

FasterCSV uses regular expressions to do the parsing where CSV just compares characters. This can lead to differences in their parsing results.

The best strategy for FasterCSV is usually to make sure you are feeding it UTF-8 encoded data and then set the encoding for your program:

$KCODE = "U"

If you need to programmatically convert the encoding, see the standard iconv library.

James Edward Gray II

By: Stefan Natchev
RE: Can't parse csv file [ reply ]  
2007-12-14 21:06
ops.
http://www.parag0n.com/test_utf8.csv
that was embarrassing...

By: Stefan Natchev
RE: Can't parse csv file [ reply ]  
2007-12-14 21:04
it looks like the character set your using is Cyrillic (windows-1251), I tried converting it to UTF-8 and FasterCSV managed to read it with no problem. here is the converted test.csv

<a href="http://www.parag0n.com/test_utf8.csv";>http://www.parag0n.com/test_utf8.csv</a>

By: Alexander Logvinov
Can't parse csv file [ reply ]  
2007-12-14 15:22
I try to move from 'cvs' to 'faster_csv' and get a problem with my csv file.

def test
require 'faster_csv'
FasterCSV.foreach("#{RAILS_ROOT}/public/test.csv") do |row|

row[2] value contains column 2,3,4 values. Why?

end
end

With 'cvs' everything was fine. Here is my cvs file: http://forback.nm.ru/test.csv