I get a CSV:MalFormedCSVError
when I try to import a file using the following code:
def import_csv(filename, model)
CSV.foreach(filename, :headers => true) do |row|
item = {}
row.to_hash.each_pair do |k,v|
item.merge!({k.downcase => v})
end
model.create!(item)
end
end
The csv files are HUGE, so is there a way I can just log the bad formatted lines and CONTINUE EXECUTION with the remainder of the csv file?
\n
, sinceFile
will treat that as the start of a new line, whereas the built in CSV library knows how to handle that appropriately. Maybe somebody else can speak to this... – Beezer