I'm importing big csv file into my rails app, but i have trouble with that, that in my file i have some russian words. I't throw me utf8 error, i tried write:
CSV.foreach("/#{Rails.public_path}/uploads/hshatem2.csv", {:encoding => 'ISO-8859-15:UTF-8', :col_sep => ';', :row_sep => :auto, :headers => :first_row}) do | row |
But then it took i part of time too (i think for encoding). Also it think about 5 hours, without encoding it would be faster, but how to do this? How to don't read russian words?
You should check out activerecord-import. CSV is not bad for smaller CSV files but gets bogged down on larger. Here is another thread on importing larger files that may help.
Additionally you might want to break out the load and iteration into two steps. So do a CSV.parse for the file and then iterate over the rows.