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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -