Skip to content

Instantly share code, notes, and snippets.

@lenage
Created July 8, 2013 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lenage/5945684 to your computer and use it in GitHub Desktop.
Save lenage/5945684 to your computer and use it in GitHub Desktop.
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