Hello all,
I’m having problems importing a simple csv into the sqlite database.
When I execute “db:migrate --trace”, I get
“FasterCSV::MalformedCSVError”. I’ve check the .csv file and made sure
that it’s UTF-8 encoded.
Here’s my migration file:
require ‘faster_csv’
class AddTestData < ActiveRecord::Migration
def self.up
Project.delete_all
array_of_arrays = FasterCSV.foreach(‘filename.csv’) do |row|
record = Project.new(
:irb_number => row[0],
:pi_full_name => row[1],
:cr_quest_split => row[2],
:cr_and_ct_split => row[3],
:old_master_list => row[4],
:title => row[5],
:status_of_irb => row[6],
:expiration_date => row[7],
:review_level => row[8],
:category => row[9],
:q2_study_coordinator_last_name => row[10],
:q2_study_coordinator_first_name => row[11]
)
record.save
end
end
“Projects” is the name of the table and all of the symbols are columns
within the table.
Any help or a pointer to a good example is appreciated.
Thanks,
JohnM