smartercsv

SmarterCSV and file encoding issues in Ruby

时光毁灭记忆、已成空白 提交于 2020-01-13 05:28:11
问题 I'm working with a file that appears to have UTF-16LE encoding. If I run File.read(file, :encoding => 'utf-16le') the first line of the file is: "<U+FEFF>=\"25/09/2013\"\t18:39:17\t=\"Unknown\"\t=\"+15168608203\"\t\"Message.\"\r\n If I read the file using something like csv_text = File.read(file, :encoding => 'utf-16le') I get an error stating ASCII incompatible encoding needs binmode (ArgumentError) If I switch the encoding in the above to csv_text = File.read(file, :encoding => 'utf-8') I

unable to run rake task with smarter_csv

你。 提交于 2019-12-13 07:01:34
问题 I created a rake task for import a csv with smarter_csv gem. Throws the following message, i added the entire error code if it helps: rake import_csv:import_csv Digest::Digest is deprecated; use Digest I, [2017-03-01T11:46:08.551994 #7029] INFO -- : ** [Raven] Raven 0.14.0 configured not to send errors. rake aborted! NoMethodError: undefined method `close' for nil:NilClass /home/my_user/.rvm/gems/ruby-2.1.1@my_app/gems/smarter_csv-1.1.4/lib/smarter_csv/smarter_csv.rb:223:in `ensure in process

ruby on rails import csv from upload file to Active Records using Smarter csv

流过昼夜 提交于 2019-12-13 04:49:22
问题 I hit a roadblock here and need help. I want to be able to import csv file to my Active Record. Either with SmarterCSV or some other way Here is my database create_table "ques", force: true do |t| t.integer "rikt_nr" t.integer "start_nr" t.integer "end_nr" t.datetime "created_at" t.datetime "updated_at" end here is my view <h2>Import Ques</h2> <%= form_tag import_ques_path, multipart: true do %> <%= file_field_tag :file %> <%= submit_tag "Import" %> <% end %> here is my route resources :ques