require 'csv' require 'pp' require 'erb' require 'time' # $ 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 => "Open Plaques", :link => "http://openplaques.org/", :description => "Documenting the historical links between people and places, as recorded by commemorative plaques." } 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 => "feedback@openplaques.org", :guid => link, :lat => row[5], :long => row[6] } items << item end puts template.result