How to change headers in a CSV file with 'CSV' then save the new headers in Ruby? -
i came across exact question i'm looking answer: "how change headers in csv file fastercsv save new headers?"
unfortunately, answer out of date because fastercsv no longer available solution.
here's example code given an answer question:
require 'fastercsv' input = file.open 'original.csv', 'r' output = file.open 'modified.csv', 'w' fastercsv.filter input, output, :headers => true, :write_headers => true, :return_headers => true |row| change_headers(row) if row.header_row? end input.close output.close
but when tried implement recommended solution in own program realized ruby no longer allows fastercsv. , command line said:
please switch ruby 1.9's standard csv library. it's fastercsv plus support ruby 1.9's m17n encoding engine.
so tried removing 'faster' everywhere said "fastercsv'. except gave me:
undefined method `change_headers' main:object (nomethoderror)
what missing here?
Comments
Post a Comment