ruby on rails - Delete values of row when import csv -
i have import csv file method carrierwave , it's works. , want delete values of row when have been successful imported database.
csv_text = file.read(file_csv.current_path) csv = csv.parse(csv_text) csv.each_with_index |row, index| @foo = foo.new(bar: row[0]) if @foo.save # delete values of row else next end end
example have file csv containing :
lenovo z360, black, 14 asus a46, blue, nil macbook pro, silver
lenovo z360 , macbook pro has been successful import, , end of process import file :
asus a46, blue, nil
is possible ? how able read, write/delete , manipule file many of row?
Comments
Post a Comment