I have a file that looks like this
ID Name Car
1 Mike Honda
2 Adam Jim
These values are tab delimited, and from this I want to parse it in Ruby and put it into my database.
I have tried the following
require 'csv'
CSV.foreach("public/files/example.tab", {:col_sep => "\t"}) do |row|
@stuff = row[0]
end
but @stuff
just returns the whole entire object, and doesn't seem to be using the column separator I specified.
It also does not take into account that the first row is a header.
How can I parse a tab delimited file in Ruby and how do I tell it that the first row is a header?