Created
September 6, 2016 07:24
-
-
Save dineshprabu-freshdesk/9b3d216fe789c6f658c6fb29ae384a47 to your computer and use it in GitHub Desktop.
Hash to csv conversion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
#writes hash to csv file | |
def write_to_csv title, hashv | |
CSV.open("#{title}.csv", "w", :write_headers=> true, :headers => hashv.first.keys) do |csv| | |
hashv.each do |h| | |
csv << h.values | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment