ruby - Why do I get "FasterCSV::MalformedCSVError: Illegal quoting error"? -
i'm driving myself slight crazy one.
i trying import csv file:
uploaded_io = file.read("amazon_import.csv") fastercsv.parse(uploaded_io, {:headers => true, :quote_char => '"', :col_sep => "\t"}).each |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 identical scripts elsewhere in app successfully, 1 throwing 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 , have tried kind of things escape or remove comma , quotes keep getting same error.
can help?
i'm on ruby 1.8.7.
Comments
Post a Comment