I’m trying to load a CSV file into my rails app using a migration and
FasterCSV and running into problems.
I’ve had this working before when the CSV file has been saved out of
excel, I’d like to do it with numbers now but I can’t quite get it to
work as is. I can’t believe that excel does a better job with CSV than
numbers (I don’t want to believe it)! The option I’m using in numbers to
do the export, is Share -> Export as CSV (set the encoding to UTF8, I
could try with a different option in numbers if that might help).
This seems like an encoding problem, is there a way I can handle this in
Here’s the error message the migration spits outâ€¦.
Unquoted fields do not allow \r or \n (line 2).
Be grateful for any help at all.
And here’s the migration fileâ€¦.
class LoadData < ActiveRecord::Migration
:row_sep => “\r”) do |row|
# name,url = row
# Contact.create(:name => name, :url => url)
:forename => forename, :job_title => jobtitle, :initials => initials, :surname => surname, :department => departmentname, :job_role => jobfunction, :company_name => companyname, :address1 => addressline1, :address2 => addressline2, :address3 => addressline3, :address4 => addressline4, :town => town, :postcode => postalcode, :country => country, :region => region, :telephone => telephone, :fax => fax, :email => email, :web => web, :personal_phone => persontelephone, :personal_fax => personfax, :personal_email => personemail ) count += 1 # puts # puts count.to_s + " Name: " + row # puts row.to_yaml # puts # puts row.inspect # puts row # puts record.url end puts count.to_s + " records inserted." records = Contact.find(:all) # puts records.count
puts “not doing anything”