An instrument I use outputs a CSV file of data, but I cannot control the column names. I would like to change the header row before importing the data (without editing the raw CSV file) so that I can use the following code to import into my database:
def self.import(file)
CSV.foreach(file.path, headers: true) do |row|
Foo.create! row.to_hash
end
end
How do I completely replace the header row with one of my own?