How to delete the entire row in the csv file in ruby 1.9.2

csv, ruby

Solution

You can fetch all the rows at once by using:

arr_of_arrs = CSV.read("path/to/file.csv")

And then you can use `arr_of_arrs.drop(1)` to remove header. Or you can use `arr_of_arrs.each_with_index` to skip the first row (header), like this:

arr_of_arrs.each_with_index do |e, i|
  next if i == 0

  #process each row here
end

Problem

I am building an app which reads the data from the CSV file and stores those data into the database. I csv file which I get from the 3rd party consists of header in the first row which has to be deleted before pushing those data in to the database. How do I delete the first row pro grammatically and then push only the values or data to the database.I am using ruby 1.9.2 version, so I dont have to use "fastercsv". I am using the standard CSV library. Kindly help me out

Original source