commit 6ce6aae3d39bcb502b424e2a6e2803e3ece91a10 Author: Adrian Short Date: Thu May 9 05:55:06 2013 -0700 diff --git a/csv2georss.rb b/csv2georss.rb new file mode 100644 index 0000000..381d7d8 --- /dev/null +++ b/csv2georss.rb @@ -0,0 +1,61 @@ +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