require 'csv' require 'pp' require 'erb' require 'time' # https://gist.github.com/adrianshort/5547284 # $ ruby csv2georss.rb myfile.csv > feed.xml template = ERB.new <<-EOF <%= channel[:title] %> <%= channel[:link] %> <%= channel[:description] %> <%= Time.now.rfc822 %> <% items.each do |item| %> <%= item[:title] %> <%= item[:link] %> ]]> <%= item[:pubDate] %> <%= item[:author] %> <%= item[:guid] %> <%= item[:lat] %> <%= item[:long] %> <% end %> EOF channel = { :title => "Plaque Guide", :link => "http://www.plaqueguide.com/", :description => "" } items = [] line = 0 CSV.foreach(ARGV[0]) do |row| line += 1 next if line == 1 # skip header row link = "http://www.plaqueguide.com/?locationid=" + row[0] item = { :id => row[0], # id :title => row[3], # location :link => link, :description => row[32], # note1 :pubDate => Time.now.rfc822, :author => "info@plaqueguide.com", :guid => link, :lat => row[5], :long => row[6] } items << item end puts template.result