خرید بک لینک

Vote count: 0

An instrument I use outputs a CSV file of data, but I caot 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?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 17 ارديبهشت 1395 ساعت: 3:23

صفحه بندی