May 4th, 2006
People in Bangalore like to eat out on Sundays
Interestingly, folks in Bombay seem to like eating out on Tuesdays:
Notes:
1. Most people seem to end up using the tag hotel when they really mean to use restaurant, so I’ve gone with the former.
2. I rely on Flickr photo data and my program. You don’t have to take the graphs seriously.
Here’s the script I wrote to draw that graph (requires flickr.rb and rgplot):
#!/usr/local/bin/ruby18
require "../flickr"
require "gnuplot"
API_KEY = "078be2728a42f4e8228f2c2b8c9b6cca"
flickrObj = Flickr::Flickr.new(API_KEY, "")
photosObj = Flickr::Photos.new
days = Hash.new { |h,k| h[k] = 0 }
photosObj.search(["#{ARGV[0]}","hotel"], "all", 0, 1000).each { |ele|
if /([0-9]+)\-([0-9]+)\-([0-9]+)/.match(photosObj.get_info(ele)["date_taken"])
begin
t = Time.mktime($1, $2, $3)
days[t.strftime("%a")] += 1
rescue
end
end
}
Gnuplot.open do |gp|
Gnuplot::Plot.new(gp) do |plot|
plot.title "Photos taken in restaurants in #{ARGV[0]}"
plot.ylabel "No. of Photos"
plot.xlabel "Days"
i = 0
plot.xtics("("+days.keys.map{|ele| "'#{ele}' #{i;i+=1}"}.join(",")+")")
plot.data << Gnuplot::DataSet.new([(1..7).to_a, days.values]) do |ds|
ds.with = "linespoints"
ds.notitle
end
end
end
Usage: ./eating-out.rb city_name
Enjoy!
Posted at 08:19 pm | Link
| 5 comments | Leave a comment





