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
You can fetch all the rows at once by using:
And then you can use
arr_of_arrs.drop(1)to remove header.Or you can use
arr_of_arrs.each_with_indexto skip the first row (header), like this: