-
-
Save tanookiben/5348566 to your computer and use it in GitHub Desktop.
Read data from githubarchive.org file and process records.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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