Created
February 21, 2012 19:18
-
-
Save yuiseki/1878268 to your computer and use it in GitHub Desktop.
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 "rubygems" | |
require "open-uri" | |
require "json" | |
require "google_spreadsheet" | |
# sudo gem install google-spreadsheet-ruby | |
if ARGV.size > 0 | |
google_name = ARGV[0] | |
google_password = ARGV[1] | |
else | |
puts "Usage: nasabatsu.rb google_name google_password" | |
end | |
jsonpath = "http://data.nasa.gov/api/get_recent_datasets/?count=100" | |
data = JSON.parse(open(jsonpath).read) | |
session = GoogleSpreadsheet.login(google_name, google_password) | |
ws = session.spreadsheet_by_key("0AlZupmnAKKoXdHBMcVFFRUctdjlZYnM0QjFqS185S1E").worksheets[0] | |
puts ws.num_rows | |
data["posts"].each_with_index do |post, i| | |
#puts JSON.pretty_generate(post) | |
puts post["url"] | |
puts post["title"] | |
# 0じゃなく1行目からスタート。そして1行目は説明が入るので2行目から。 | |
ws[i+2, 1] = post["url"] | |
ws[i+2, 2] = post["title"] | |
end | |
ws.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment