Skip to content

Instantly share code, notes, and snippets.

@tanookiben
Forked from igrigorik/read_activity.rb
Last active December 16, 2015 00:38
Show Gist options
  • Save tanookiben/5348566 to your computer and use it in GitHub Desktop.
Save tanookiben/5348566 to your computer and use it in GitHub Desktop.
Read data from githubarchive.org file and process records.
require 'open-uri'
require 'zlib'
require 'yajl'
gz = open('http://data.githubarchive.org/2012-03-11-12.json.gz')
js = Zlib::GzipReader.new(gz).read
events = [] # list of each event for the specified date based on predefined event types
Yajl::Parser.parse(js) do |event|
# puts event <-- not particularly useful in demoing how to actually see the data
events << event
end
events_hash = {}
Yajl::Parser.parse(js) do |event|
key = event["type"]
if events_hash[key].nil?
events_hash[key] = []
end
events_hash[key] << event
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment