Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert csv file to YAML
require 'csv'
class String
def unquote
self.gsub(/^"|"$/, '')
end
end
# first line contains the field names
#line = gets
#fields = line.split('","').collect {|f| f.unquote.chomp}
CSV::Reader.parse(STDIN) do |row|
fixture = "linepro_#{row[0]}:\n"
fixture += " tl_shop_id: \"#{row[1]}\"\n"
puts fixture; puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.