I have a CSV file and I want to merge these entries into an existing CSV file. However, two files have headers that are named differently. How can I cleanly and efficiently rename CSV headers to combine the file I'm merging with?
Answer:
CSV::HeaderConverters[:map_to_main] = lambda do |header| # work your magic here header end CSV.open(file, headers: true, header_converters: :map_to_main).to_a.map(&:to_hash)