I'm driving myself slight crazy with this one.
I am trying to import a CSV file:
uploaded_io = File.read("amazon_import.csv")
FasterCSV.parse(uploaded_io, {:headers => true, :quote_char => '"', :col_sep => "\t"}).each do |row_data|
new_record = AmazonSale.new(
'asin' => row[0],
'title' => row[1],
'barcode' => row[2].match(/\d+/),
'price' => row[4],
'discount' => row[5],
'cost' => row[7],
'active' => row[8],
'product_group' => row[9],
'release_date' => row[10],
'customer_ordered_units' => row[11],
'shipped_units' => row[12],
'shipped_date' => Date.today - 1,
'shipped_cogs' => row[14],
'sellable_on_hand_units' => row[15],
'unsellable_on_hand_units' => row[16],
'customer_owned' => row[17],
'total_inventory_units' => row[18],
'vendor_units_received' => row[19],
'open_po_qty' => row[20],
'two_week_forecast' => "",
'four_week_forecast' => "",
'category' => "",
'subcategory' => "",
'author' => row[25],
'binding' => "",
'platform' => "",
'cat_no' => row[28]
)
new_record.save
end
I use almost identical scripts elsewhere in my app successfully, but this one is throwing an error like:
FasterCSV::MalformedCSVError: Illegal quoting in line 70.
The offending line looks like:
0711297466621,£,5.56,20,£,4.45,Active,Music,06/10/2003,2,5,£,22.25,0,0,4,4,1,27,Alternative & Indie,Unknown,"Bragg, Billy",Audio CD,cd,COOKCD266,,
I can see it's "Bragg, Billy" causing this and have tried all kind of things to escape or remove the comma and quotes but I keep getting the same error.
Can anyone help?
I'm on Ruby 1.8.7.