Created
September 24, 2014 14:49
-
-
Save jrcryer/d7f2c92e8253d6c57fb1 to your computer and use it in GitHub Desktop.
DynamoDB Ruby
This file contains 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 'rubygems' | |
require 'aws-sdk' | |
dynamo_db = AWS::DynamoDB.new | |
table = dynamo_db.tables['table-name'] | |
table.load_schema | |
table.items.each do |incident| | |
attributes = incident.attributes.to_hash | |
locations = attributes['locations'] | |
gz = Zlib::GzipReader.new(StringIO.new(locations.to_s)) | |
json = gz.read | |
locations = JSON.parse(json) | |
locations.each do |loc| | |
unless loc['junctionNumber'].nil? | |
puts attributes['incidentId'].to_i | |
puts attributes['summary'] | |
puts loc | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment